vue服務器渲染按需引入mint-uijavascript
1.修改.babelrc文件,在.babelrc文件中plugins數組中添加vue
{ "presets": [["es2015", { "modules": false }], "stage-2"], "ignore": ["node_modules/*"], "plugins": [["component", [ { "libraryName": "mint-ui", "style": true } ]]] }
2.在.vue文件中引入使用就能夠了java
<script> import Vue from 'vue' import { Button, Toast } from 'mint-ui' Vue.component(Button.name, Button) export default { name: 'MintUi', created() {}, computed: {}, asyncData({ store }) {}, methods: { handleClick() { Toast('Hello word') } } } </script>
這樣就能夠了。node
若是如今運行報Unknown plugin "component" specified in 。。。的錯npm
能夠執行npm install babel-plugin-component -D就能夠了數組