#小程序# mpvue引入vant的注意事項

- 安裝vant
	- npm install vant-weapp -S --production
- 引用
	- /app.json
	"usingComponents": {
    "van-button": "vant-weapp/dist/button/index"
  }

- 使用	
	<template>
	    <div id="hello">
	        hello world!!! <van-button type="primary">click</van-button>
	    </div>
	</template>

- webpack.base.config.js配置
	- 作用: 在編譯的時候在小程序中複製node_modules文件加下的vant-app/dist目錄
	if (/^wx$/.test(PLATFORM)) {
	  baseWebpackConfig = merge(baseWebpackConfig, {
	    plugins: [
	      new CopyWebpackPlugin([{
	          from: resolve('node_modules/vant-weapp/dist'),
	          to: resolve('dist/wx/vant-weapp/dist'),
	          ignore: ['.*']
	      }])
	    ]
	  })
	}

- 小程序項目配置
	- 勾選 ES5 轉成 ES6
	- 一定要勾選, 否則運行會報錯
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章