Use HBuilder X to develop Vue3+node+element-plus

There are many tools for developing Vue3, such as VSCode, which is also very easy to use. This article mainly uses HBuilder X for development.

3 environments:

Windows10

12e7d36e82e9437d9c96534ffaefd88d.png

Node installation

1. Open the official website, select a version, and install it

Node.js

f15e300214b84127994d81987f9cf2d3.png

2. Select the path, the next step is fine 

c34fb225622e40669a192174eef8129a.png

3. Enter the command to see the version

node -v

3598d6242cba403ead23a2cbd44ebb74.png

4. Then enter the command to install the domestic Taobao mirror, so that the speed is faster

npm install -g cnpm --registry=https://registry.npm.taobao.org

0bddfc9d514044bb9a257aca1052c1cf.png Prompt let's upgrade, we can upgrade, we can not upgrade.

5. We choose to upgrade, skip this step if you don’t want to upgrade

Enter the command in green font

npm install -g [email protected]

35af4b8636a04c3cb80f66d40260fec6.png

6. Then enter the command for global installation

cnpm install vue-cli -g

d73424e5f7304bde9dc3c565d8041467.png

6. Check whether the installation is successful

vue -V

7f7561ae8040433dbd8e7a97856a4709.png

At this point, the environment installation is complete! ! If you are unsuccessful, try more, the installation environment is already a very troublesome thing.

 Back to the topic, build a Vue3 project

 1. After the download is complete, open the development software

e3cf6d65f8bc41a9b68b1239be768c86.png

2. Select the file, write the project name and path, select version 3.28, and create

febc1ded47c94fc7b633f2f39990e746.png

3. The order of file execution

First index.html->main.js->App.vue->HelloWorld.vue

Open the file and look carefully, you can see the order, like nesting dolls, layer by layer

0200de3dace8412ba46c674f76c6c7c7.png

4. Click Run and select the built-in browser

If not, just download it

2a6d836474aa43d9a8fd1af2c54e095a.png

You can also choose the browser, so that you can browse outside

e294947697b2407ba8c4216637e95ae3.png

In fact, it worked. 

5. Next, we install element-plus and select as shown in the figure

fa936fec2fe4427e9bbd85b381dd4558.png

6. Enter the command

If the network is good, use npm

npm install element-plus --save

If the network is not good, use cnpm 

cnpm install element-plus --save

283dbc12749249ae87b5384990aae60b.png

7. If there is an error, see the extension, if there is no error, just see the fifth step of the extension.

expand

Install element-plus error as shown below

3e25b7cc47d24a11842bbecf72a1516e.png

reason:

There aec6680709014dd2b28d41ef2c65d634.png is an error in this file, so it causes a compilation error.

Solution: So, after we uninstall the content inside, and then download it again. Finally I know the reason, here is my computer's global error, now just delete it separately, and then install it separately.

1. Open the path of this project. Execute in sequence to uninstall

cnpm cache clean
rm -rf node_modules
rm package-lock.json
npm cache clear --force

2. After the execution is completed, there will be no node_modules folder

e44dcb43ed8c44eaa73d64629a0c0fff.png

3. Execute the following commands in sequence

cnpm install 
cnpm run dev
cnpm run serve

4. node_modules have

020b0b642ea644d480c01f661a47a16f.png

5. Install element-plus

cnpm install element-plus --save

b59555f930bc4a80a43f94fb25a392a1.png

6. Modify main.js as follows

import { createApp } from 'vue'
import App from './App.vue'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

const app = createApp(App)

app.use(ElementPlus)
app.mount('#app')

Then copy the component of element-plus

  <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>

7. Then right-click on demoVue3 and choose to operate

e998739eb0014ea0ae57a3e4683a03a4.png

 result 

b9fd0ec5fc5447fc8b3081ae25a423f9.png

8. Then run the project, success!

f2a6ff53c2154e76acf2a91f1a8188ec.png

Supongo que te gusta

Origin blog.csdn.net/u012563853/article/details/128103519
Recomendado
Clasificación