vue2.0 + vux 項目搭建


1、快速搭建項目模板

因為項目使用vux,所以推薦使用vux官網的airyland/vux2 模板,vue-cli工具是vue項目的搭建腳手架

默認為 webpack2 模板,如果你需要使用webpack1,請使用 vue init airyland/vux2#webpack1 projectPath

npm install vue-cli -g // 如果還沒安裝
vue init airyland/vux2 projectPath

cd projectPath
npm install --registry=https://registry.npm.taobao.org
npm run dev

請特別注意,直接使用 cnpm 可能會導致依賴不正確。強烈建議給 npm 設置 taobao 的 registry。 

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

如果你已經用上了 yarn,建議這樣 

yarn config set registry https://registry.npm.taobao.org 
yarn

2、運行模板文件

打開本地8080端口可以看到模板運行如下

注意:如包安裝沒有報錯,npm run dev報錯,很可能是8080端口沖突

3、安裝 less

npm install less less-loader --save-dev

4.main.js  全局注冊 toast  /  alert  /  loading

// 全局引入 loading/toast/alert
import { LoadingPlugin, ToastPlugin, AlertPlugin } from 'vux'
Vue.use(LoadingPlugin)
Vue.use(ToastPlugin)
Vue.use(AlertPlugin)

5.調用

// 顯示等待框
this.$vux.loading.show({
  text: '加載中...'
});

// 隱藏等待框
setTimeout(() => {
  this.$vux.loading.hide()
}, 300);

 

// 提示信息
this.$vux.toast.show({
  type: 'text',
  position: 'middle',
  text: '請輸入查詢內容!'
});

.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM