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

来源:互联网 发布:linux mount rw 编辑:程序博客网 时间:2024/05/29 08:50

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 0