1、安装vue-layer插件

  1. npm install vue-layer --save-dev

2、打包入口文件main.js中引入vue、vue-layer、并且将vue-layer添加到vue原型

  1. import Vue from 'vue';
  2. import layer from 'vue-layer'
  3. Vue.prototype.$layer = layer(Vue);

3、然后打包报如下错误

  1. ERROR in ./node_modules/vue-layer/dist/vue-layer.js
  2. Module build failed (from ./node_modules/babel-loader/lib/index.js):
  3. ReferenceError: Unknown plugin "transform-runtime" specified in "C:\\Users\\defaultuser0\\Study\\Web\\webpack_vue\\node_modules\\vue-layer\\.babelrc" at 0, attempted to resolve relative to "C:\\Users\\defaultuser0\\Study\\Web\\webpack_vue\\node_modules\\vue-layer"
  4. at C:\Users\defaultuser0\Study\Web\webpack_vue\node_modules\babel-core\lib\transformation\file\options\option-manager.js:180:17
  5. at Array.map (<anonymous>)
  6. at Function.normalisePlugins (C:\Users\defaultuser0\Study\Web\webpack_vue\node_modules\babel-core\lib\transformation\file\options\option-manager.js:158:20)
  7. at OptionManager.mergeOptions (C:\Users\defaultuser0\Study\Web\webpack_vue\node_modules\babel-core\lib\transformation\file\options\option-manager.js:234:36)
  8. at OptionManager.init (C:\Users\defaultuser0\Study\Web\webpack_vue\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
  9. at File.initOptions (C:\Users\defaultuser0\Study\Web\webpack_vue\node_modules\babel-core\lib\transformation\file\index.js:212:65)
  10. at new File (C:\Users\defaultuser0\Study\Web\webpack_vue\node_modules\babel-core\lib\transformation\file\index.js:135:24)
  11. at Pipeline.transform (C:\Users\defaultuser0\Study\Web\webpack_vue\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
  12. at transpile (C:\Users\defaultuser0\Study\Web\webpack_vue\node_modules\babel-loader\lib\index.js:50:20)
  13. at Object.module.exports (C:\Users\defaultuser0\Study\Web\webpack_vue\node_modules\babel-loader\lib\index.js:173:20)
  14. @ ./src/main.js 19:16-36

4、解决上面错误

  1. npm install babel-plugin-transform-runtime --save-dev
  2. npm install babel-preset-stage-0 --save-dev

5、vue中使用无效,浏览器审查报错

  1. this.$layer.alert('123');
  2.  
  3. 使用layer报错:
  4. vue.runtime.esm.js:575 [Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
  5. (found in <Root>)

6、解决上面无法使用问题

  1. webpack.dev.js配置文件中添加:
  2. resolve:{
  3. alias:{
  4. 'vue$':'vue/dist/vue.js'
  5. }
  6. },

7、再次使用,成功

  1. mounted() {
  2. console.log(this.$layer);  //打印这个对象的所有方法
  3. //this.$layer.alert("找不到对象!");
  4. this.$layer.confirm('添加成功!',{
  5. type: 0, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  6. title: '自定义', //弹框的标题
  7. area: 'auto',
  8. offset: 'auto',
  9. icon: -1,
  10. btn: '确定',
  11. time: 0,
  12. shade: true, //是否显示遮罩
  13. tips: [0, {}], //支持上右下左四个方向,通过1-4进行方向设定,可以设定tips: [1, '#c00']
  14. tipsMore: false, //是否允许多个tips
  15. shadeClose: true, //点击遮罩是否关闭
  16. });
  17. },

详细使用参数参考:https://www.npmjs.com/package/vue-layer

webpack+vue中安装使用vue-layer弹窗插件的更多相关文章

  1. JBPM4入门——2.在eclipse中安装绘制jbpm流程图的插件

    本博文只是简要对JBPM4进行介绍,如需更详细内容请自行google 链接: JBPM入门系列文章: JBPM4入门——1.jbpm简要介绍 JBPM4入门——2.在eclipse中安装绘制jbpm流 ...

  2. vue 中安装使用sass 报错遇到的问题整理

    不出错的情况下,正常安装: 1.安装包: npm install node-sass --save-dev npm install sass-loader --save-dev (sass-loade ...

  3. 【vue】vue.js安装教程/vue项目搭建

    前提:已安装nodejs——npm  (备注教程  “物理安装”  ) 第一步:建了一个managerSys文件夹,用于保存项目 第二步:从cmd进入该文件夹,之后开始安装vue.js相关 1)在该项 ...

  4. vue中自定义指令vue.direvtive,自定义过滤器vue.filter(),vue过渡transition

    自定义指令 默认设置的核心指令( v-model,v-bind,v-for,v-if,v-on等 ),Vue 也允许注册自定义指令.注意,在 Vue2.0 里面,代码复用的主要形式和抽象是组件——然而 ...

  5. chrome中安装.crx后缀的离线插件

    在前端开发中常常需要在chrome中安装一些插件辅助开发,比如最常用的Postman.React Developer Tools.Vue.js devtools等等...今天分享一下不需要“FQ”的插 ...

  6. 在vue中安装使用vux

    最近因为的工作的原因在弄vue,从后端弄到前端之前一直用js,现在第一次接触vue感觉还挺有意思的,就是自己太菜了,这个脑子呀....不太够用.....页面设计用了一个叫vux的东西,vux可以提供一 ...

  7. vue中封装一个全局的弹窗js

    /** * Created by yx on 2017/12/21. */ export default { /** * 带按钮的弹框 * <!--自定义提示标题,内容,单个按钮事件--> ...

  8. 033——VUE中安装使用vue-devtools调试工具用于监控数据变化

    vue官网:https://cn.vuejs.org/ 下的官方仓库:vue-devtools  安装到火狐或谷歌下都可以,安装成功之后,按F12查看就可以了

  9. vue中引入swiper(vue中的滑块组件vue-awesome-swiper)

    第一步安装 npm install vue-awesome-swiper --save 第二部在main.js中引入 import VueAwesomeSwiper from 'vue-awesome ...

随机推荐

  1. Going Home(最小费用最大流)

    Going Home http://poj.org/problem?id=2195 Time Limit: 1000MS   Memory Limit: 65536K Total Submission ...

  2. UISearchDisplayController 阴影遮盖frame调整

    iOS7中UISearchDisplayController 与UISearchBar结合使用时,有时候会出现搜索框获得焦点时,阴影遮盖部分挡住了搜索框,影响用户使用,如下图 API中没有阴影图层的接 ...

  3. [Selenium]重写拖拽dragWidgetToElementContainner()

    public void dragWidgetToElementContainner(String widgetName, String targetPosition){ WebElement widg ...

  4. Java 设计模式系列(一)单例模式

    Java 设计模式系列(一)单例模式 保证一个类只有一个实例,并且提供一个访可该实例的全局访问点. 一.懒汉式单例 /** * 懒汉式单例类:在第一次调用的时候实例化自己 * 1. 构造器私有化,避免 ...

  5. 微交互:App成功的秘诀

    以下内容由Mockplus团队翻译整理,仅供学习交流,Mockplus是更快更简单的原型设计工具. 最好的产品拥有两个很棒的特点:功能和细节.产品的功能可成功吸引到人们的注意力,而产品的细节则可留住你 ...

  6. 查看linux服务器状态常用命令

    最近发现大数据技术的一些部署.高可用.集群等和网站的负载均衡.自动化运维.灾备等其实有很多知识都是重合的,要学好linux运维相关,在大数据的研究上也会有所提高.既然工作需要去系统的去学习linux运 ...

  7. SOCKET句柄泄露带来的内存灾难

    前些时候游戏莫名其妙出现大量内存泄露,我感到很诧异,当然一般情况下游戏的内存管理是极其严苛的,出现如此大量的内存泄露到底是怎么回事? 句柄滥用导致的内存泄露会多夸张呢,尤其SOCKET,在某些客户端系 ...

  8. iOS密码输入框的实现

    [iOS密码输入框的实现] 就是一个UITextField,把属性 UITextField.secureTextEntry设置为Yes即可.此种UI效果为iOS默认效果.

  9. 455. Assign Cookies

    static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); class Solution { publ ...

  10. ldap域账号登录

    $host = "iflytek.com"; $user = 'yimiao@'.$host;//'用户名@域名'; $pswd = "******"; //1 ...