<template>
<!--
// replaced @input="$emit('input', $event.target.value)" with
// v-on="$listeners", need testing
// see more here
// http://blog.webf.zone/vue-js-considerations-and-tricks-fa7e0e4bb7bb
-->
<div>
<label class="form-label">{{ getLabel | capitalize }}</label>
<input
v-tooltip="getTooltipContent"
:bind="$attrs"
:type="type"
:value="value"
:placeholder="getPlaceHolder"
:class="getClass"
class="form-input"
data-vv-validate-on="none"
v-on="{
...$listeners,
input: event => $emit('input', event.target.value)
}">
</div>
</template>
修改我的代码后(上面 v-on ),我得到了
Summary of all failing tests
FAIL src/apps/common/components/tables/reports-table.unit.js
● Test suite failed to run
Object spread operator requires specified objectAssign option with 'Object.assign' or polyfill helper. (1:412)
at Node.transpile (node_modules/vue-template-es2015-compiler/buble.js:12676:11)
at node_modules/vue-template-es2015-compiler/buble.js:5864:59
at Array.forEach (<anonymous>)
at Node.transpile (node_modules/vue-template-es2015-compiler/buble.js:5864:10)
at Node.transpile (node_modules/vue-template-es2015-compiler/buble.js:6553:28)
at node_modules/vue-template-es2015-compiler/buble.js:5864:59
at Array.forEach (<anonymous>)
at Node.transpile (node_modules/vue-template-es2015-compiler/buble.js:5864:10)
at Node.transpile (node_modules/vue-template-es2015-compiler/buble.js:6553:28)
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": [
"jsx-vue-functional",
"transform-vue-jsx",
"transform-runtime",
"transform-decorators-legacy",
"transform-object-rest-spread",
"transform-es2015-destructuring",
],
"env": {
"test": {
"presets": ["env", "stage-2", "jest"],
"plugins": [
"transform-vue-jsx",
"transform-es2015-modules-commonjs",
"dynamic-import-node",
"transform-decorators-legacy",
"transform-object-rest-spread",
"transform-es2015-destructuring",
]
}
}
}
'use strict'
const utils = require('./utils')
const config = require('../config')
const isProduction = process.env.NODE_ENV === 'production'
const sourceMapEnabled = isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap
module.exports = {
loaders: utils.cssLoaders({
sourceMap: sourceMapEnabled,
extract: isProduction
}),
cssSourceMap: sourceMapEnabled,
cacheBusting: config.dev.cacheBusting,
transformToRequire: {
video: ['src', 'poster'],
source: 'src',
img: 'src',
image: 'xlink:href'
},
buble: {
objectAssign: 'Object.assign'
}
}
** 我的.babelrc **中已经有第二阶段和transform-object-rest-spread了。