Vue-Element入門(一、安裝Vue-Element)

一、安裝 webpack

全局安裝
npm install webpack -g
npm i webpack-cli -g
查看安裝
webpack -v

二、安裝vue-cli

npm install -g @vue/cli

三、創(chuàng)建項(xiàng)目

//name是項(xiàng)目的名稱,可以改成非中文字體的任意名稱
vue create  name

四、安裝依賴

進(jìn)入項(xiàng)目文件夾后執(zhí)行 npm install
cd name
npm install 

五、安裝和設(shè)置element-ui

官網(wǎng):https://element.eleme.cn

安裝element-ui
npm i element-ui -S
在main.js 中寫入以下內(nèi)容進(jìn)行引入(路徑src/main.js
import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

Vue.use(ElementUI)
Vue.config.productionTip = false

new Vue({
  render: h => h(App),
}).$mount('#app')
src/app.vue修改為
<template>
 <div id="app">
<el-button @click="show">測(cè)試</el-button>
 </div>
</template>
<script>
export default {
 name: 'App',
 methods:{
   show(){
     //this.$message('element-ui-測(cè)試提示1')
     this.$message.success('element-ui-測(cè)試提示2')
   }
 }
}
</script>
<style>
#app {
}
</style>
運(yùn)行vue項(xiàng)目
npm run serve
成功后訪問 http://localhost:8080
訪問后點(diǎn)擊測(cè)試按鈕出現(xiàn)如下內(nèi)容,表示成功
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容