vue使用mui
mui github 链接:https://github.com/dcloudio/mui
下载mui后将起文件dist下的文件复制到vue项目static下新建mui文件目录
再main.js中
// // 引入mui组件
import mui from '../static/mui/js/mui.js'
Vue.prototype.mui = mui
//引入其样式
import "../static/mui/css/mui.css";
再使用mui组件的时候要通过this来访问
- 列子 轮播图初始化
var gallery = this.mui('.mui-slider');
gallery.slider({
interval:1000//自动轮播周期,若为0则不自动播放,默认为0;
});
最后有一点 打包的时候因为mui.css 的svg问题 会出现以下报错
building for production...Error processing file: static/css/app.316977a049dccd7ae4089d9226e81a34.css
(node:11888) UnhandledPromiseRejectionWarning: postcss-svgo: Error in parsing SVG: Unquoted attribute value
Line: 0
Column: 14
Char: \
(node:11888) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:11888) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
解决方法
ctrl+f
做出svg 然后将起src最外层的单引号换成双引号
- mui.css 和mui.mim.css都要修改 或者你可以选择删掉一个 QAQ
最后 npm run build
就OK啦
关于打包后的路劲问题
去config下的
index.js
中 的build
下的assetsPublicPath
换成./
关于字体图标打包后无法显示
需要找到webpack.base.conf.js 文件把之前的默认的处理tff文件的中的tff删掉,新增一条:
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, use: 'url-loader' },
到此打包后的文件应该是没有问题了