vue使用vue-ueditor碰到的问题(Couldn't find preset "es2015" relative to directory)

1、安装vue-ueditor

npm i vue-ueditor --S

将安装包下面的UEditor 代码包复制到项目static目录下面

UEditor 代码包(\node_modules\vue-ueditor\static\ueditor1_4_3_3)或者在下载最新源码和各个语言版本的http://ueditor.baidu.com/website/download.html#ueditor

2、使用

<template>
    <div>
      <p>fdgdgd</p>
      <VueEditor ueditorPath="../../static/ueditor1_4_3_3-utf8-net" @ready="editorReady"></VueEditor>
    </div>
</template>

import  VueEditor from  'vue-ueditor'
 components:{
            VueEditor
        },
      methods:{
            editorReady(editorInstance){
              editorInstance.setContent('Hello world!<br>编辑初始化内容')
            }
      }

3、Couldn't find preset "es2015" relative to directory问题解决

由于是菜鸟没使用ES标准,而引入的vue-ueditor使用了ES标准,所以编译会报错,解决办法如下:

npm install babel-preset-es2015 --save-dev
然后需要在webpack.base.conf.js文件中加入如下代码

module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: /(node_modules|bower_components)/,
                loader: 'babel',
                query: {
                    presets: ['es2015']
                }
            }
        ]
    }
ok,现在可以使用vue-uediter了

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值