Vue-loader无法识别es2015语法

时间:2016-04-28 19:16:12

标签: ecmascript-6 webpack vue.js vue-loader

我遇到了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-server在localhost:8080上成功托管。

当我修改App.vue并添加任何es2015时,我从webpack-dev-server收到错误:

<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>

example of error

这让我觉得没有安装es2015预设的babel,但它肯定在dev依赖列表中与transform-runtime一起使用:

// 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-loader提供了许多很酷的功能:

     

默认启用ES2015;

我缺少一个步骤或配置吗?

版本:

  • vue-cli:2.0.3
  • npm:3.8.6
  • node:6.0.0

1 个答案:

答案 0 :(得分:1)

我认为应该是

 DECLARE @str VARCHAR(100) = '|GADS~55.0*BILK~0.0*BOBB~81.0*HETT~32.0*IGGR~51.0|';

 WITH Cut1 AS
(
    SELECT SUBSTRING(@str,CHARINDEX('~',@str,1)+1,1000) AS c1
)
,Cut2 AS
(
    SELECT SUBSTRING(Cut1.c1,1,LEN(Cut1.c1)-1) + '*' AS c2 FROM Cut1
)
,Splitted AS
(
    SELECT CAST('<x>' + REPLACE(Cut2.c2,'~','</x><x>') + '</x>' AS XML) AS AsXML FROM Cut2
)
SELECT SUM(CAST(SUBSTRING(numbers.value('.','varchar(100)'),1,CHARINDEX('*',numbers.value('.','varchar(100)'),1)-1) AS FLOAT))
FROM Splitted
CROSS APPLY AsXML.nodes('/x') AS the(numbers)

ready: () => alert('worked')