nuxtjs中单独引入Message组件的问题

2020-03-16 15:57:53

参考地址 element-ui中单独引入Message组件的问题

需要注意的事项,貌似nuxtjs中引入只需要下面的第四步就可以了。然后记得引入相应的css代码,否则很难看,代码,去element源码中去找。


1.安装elementui

npm i element-ui -S

2.安装 babel-plugin-component

npm install babel-plugin-component -D

3.找到.babelrc 把原文件内容全部删除,粘贴下面代码

{ "presets": [["env", {"modules": false,"targets": {"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]}}],"stage-2"],"plugins": ["transform-runtime",["component",[{"libraryName":"element-ui","styleLibraryName":"theme-default" //1.4的老项目用这个,2.0的用theme-chalk,假设没效果看看官网又把默认的主题改 成那个了 跟着改一下应该就可以了}]]],"comments":false,"env": {"test": {"presets": ["env", "stage-2"],"plugins": ["istanbul"]}}}

4.在mian.js中引入

// 引入elementUIimport { Message  } from 'element-ui';//由于Message组件并没有install 方法供Vue来操作的,是直接返回的,因此按照官方文档单独引入的方法是//会报错的,需要给 Message 添加 install 方法Message.install = function (Vue, options) {Vue.prototype.$message = Message}Vue.use(Message )//消息提示

组件中不需要引入,可以直接用了


  • 2017-11-10 00:06:15

    CORS: credentials mode is 'include'

    XMLHttpRequest cannot load http://localhost/Foo.API/token. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:5000' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

  • 2017-11-19 00:17:51

    Java如何获取Date的“昨天”与“明天”示例代码

    最近在做项目的时候用到Date和Calendar比较多,而且用到的方式也比较全,突然想到一个问题,Java如何获取Date的"昨天"与"明天",也就是前一天和后一天呢?思考后写出了方法,想着万一以后用到,就总结出来,也方便有需要的朋友们参考借鉴,下面来一起看看吧。