0
我遇到vue-loader存在問題,無法識別es2015格式。Vue-loader無法識別es2015語法
這裏是我採取的步驟:
//initialize the project via vue-cli
vue init webpack-simple && npm i
// start the webpack-dev-server, this npm script is an alias for the command:
// webpack-dev-server --inline --hot
npm run dev
此時在本地主機中的文件正在由的WebPack-dev的服務器託管:8080成功。
當我修改App.vue
並添加任何東西在ES2015我得到的WebPack-dev的服務器錯誤:
<template>
<div id="app">
<h1>{{ msg }}</h1>
</div>
</template>
<script>
export default {
data() {
return {
msg: 'Hello Vue!'
}
},
// added this function call for the ready lifecycle hook
ready() => alert('worked')
}
</script>
<style>
body {
font-family: Helvetica, sans-serif;
}
</style>
這讓我覺得這是沒有安裝巴貝爾ES2015預置,但它肯定在開發依賴列表以及變換運行時:
// truncated package.json
{
...
"scripts": {
"dev": "webpack-dev-server --inline --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"vue": "^1.0.0",
"babel-runtime": "^5.8.0"
},
"devDependencies": {
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-plugin-transform-runtime": "^6.0.0",
"babel-preset-es2015": "^6.0.0",
"babel-preset-stage-2": "^6.0.0",
"cross-env": "^1.0.6",
"css-loader": "^0.23.0",
"file-loader": "^0.8.4",
"json-loader": "^0.5.4",
"url-loader": "^0.5.7",
"vue-hot-reload-api": "^1.2.0",
"vue-html-loader": "^1.0.0",
"vue-loader": "^8.2.1",
"vue-style-loader": "^1.0.0",
"webpack": "^1.12.2",
"webpack-dev-server": "^1.12.0"
}
}
加上docs for vue-loader說,ES2015是默認啓用:
有由VUE裝載機提供了很多很酷的功能:
ES2015默認啓用;
是否有我失蹤的步驟或配置?
版本:
- VUE-CLI:2.0.3
- NPM:3.8.6
- 節點:6.0.0
Oopf!這是一個重要的人臉圖。感謝您指出了這一點! –