网络上如何推广网站,工作总结ppt模板免费下载,长春网站建设有什么,wordpress页底白首先确保安装的nodejs是18版本以上
确保你安装了最新版本的 Node.js#xff0c;并且你的当前工作目录正是打算创建项目的目录。在命令行中运行以下命令
VSCode打开终端
输入构建项目命令#xff0c;个人推荐如果有cnpm使用cnpm
npm create vuelatest
cnpm create vuelate…首先确保安装的nodejs是18版本以上
确保你安装了最新版本的 Node.js并且你的当前工作目录正是打算创建项目的目录。在命令行中运行以下命令
VSCode打开终端
输入构建项目命令个人推荐如果有cnpm使用cnpm
npm create vuelatest
cnpm create vuelatest 创建成功之后 引入element依赖包
cnpm i element-ui -S 完整引入
在 main.js 中写入以下内容
import Vue from vue;
import ElementUI from element-ui;
import element-ui/lib/theme-chalk/index.css;
import App from ./App.vue;Vue.use(ElementUI);new Vue({el: #app,render: h h(App)
});以上代码便完成了 Element 的引入。需要注意的是样式文件需要单独引入。 按需引入
借助 babel-plugin-component我们可以只引入需要的组件以达到减小项目体积的目的。
首先安装 babel-plugin-component
npm install babel-plugin-component -D然后将 .babelrc 修改为
{presets: [[es2015, { modules: false }]],plugins: [[component,{libraryName: element-ui,styleLibraryName: theme-chalk}]]
}接下来如果你只希望引入部分组件比如 Button 和 Select那么需要在 main.js 中写入以下内容
import Vue from vue;
import { Button, Select } from element-ui;
import App from ./App.vue;Vue.component(Button.name, Button);
Vue.component(Select.name, Select);
/* 或写为* Vue.use(Button)* Vue.use(Select)*/new Vue({el: #app,render: h h(App)
});