赞
踩
强烈建议先把这篇文章学习了《通过安装Element UI/Plus来学习vue之如何创建项目、搭建vue脚手架、npm下载等》
下载node.js,安装完node.js自然就安装好了npm。
本机安装了npm
后才可以正常使用安装启动命令。
HBuilder只是一个开发环境,可以借用其自带的项目生成功能,这和使用命令vue init webpack Admin
创建项目生成的目录文件结构略有不同。
右键点击项目,打开命令行窗口,以保证你的命令是用于该目录的。
npm run dev
当然也可以利用HBuilder快速执行命令
执行成功后会给出测试地址和端口。
在浏览器中使用提供的http://localhost:3000/
打开页面,
npm install element-plus
或
npm install element-plus --save
根据自己需求来。
node_modules
目录存在@element-plus
文件夹package.json
中已经标记了element-plus
官方介绍:https://element-plus.org/zh-CN/guide/quickstart.html
Admin/src/main.js
,代码如下:import { createApp } from 'vue'
import App from './App.vue'
createApp(App).mount('#app')
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
//createApp(App).mount('#app')
const app = createApp(App)
app.use(ElementPlus)
app.mount('#app')
Admin/src/components/HelloWorld.vue
页面中添加element-plus 按钮
<el-row class="mb-4">
<el-button>Default</el-button>
<el-button type="primary">Primary</el-button>
<el-button type="success">Success</el-button>
<el-button type="info">Info</el-button>
<el-button type="warning">Warning</el-button>
<el-button type="danger">Danger</el-button>
<el-button>中文</el-button>
</el-row>
npm run build
或使用HBuilder自带的
dist
文件夹在浏览器中运行dist
目录中的网站,发现页面显示为空白~~
打开index.html
可以看到路径为根目录,怎么办呢?总不可能每次打包时都去手动改写吧~~
vue3版本和vue2版本修改方式有所不同,HBuilder使用vite,修改方式也可能有所不同哦~~
Admin/vite.config.js
base:'./'
目录路径npm run build
打包后问题解决vue3-cli项目
element-plus
为vue3项目,使用cli脚手架当然很有必要
运行开发环境dev
和运行生产环境build
npm run dev
npm run build
npm install [组件名]
[项目名]/vite.config.js
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。