将Vue2-timepicker导入为单个文件组件时出现Webpack错误

时间:2018-09-20 07:48:27

标签: vue.js webpack vuejs2 vue-component

当我尝试将Vue2-timepicker导入为单个文件组件时,出现以下错误。

  

未捕获的错误:模块构建失败:TypeError:this._init与函数不一样

代码

import Vue from 'vue'
import request from 'superagent'
import { swapEnterKeyWithTab } from '../../lib/enter_as_tab'
import moment from 'moment'
import DatePicker from 'vuejs-datepicker'
import VueTimepicker from 'vue2-timepicker'

const FOREIGN_ATTRS = ['totals', 'baghouse_alarm_attributes', 'readings_attributes']

export default Vue.component('production-report-form', {
props: ['recordData', 'disabled'],
data: function() {
return { record: setData(this), alert: null }
},

mounted: function() {
swapEnterKeyWithTab()
this.determineBalance()
},
components: {
DatePicker,
VueTimepicker
},

Webpack.config.js

// plugins: [new webpack.HotModuleReplacementPlugin()],
devtool: 'source-map',
module: {
  loaders: [
   {
    test: /\.js?/,
    include: APP_DIR,
    loaders: ['babel-loader'],
    exclude: /node_modules[.*|\/](?:(?!common-fe))/
   },
   {
    test: /\.scss$/,
    loaders: ['style', 'css', 'sass']
   },
   {
test: /\.vue$/,
loaders: ['vue']
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.js'
}
}

Reference

0 个答案:

没有答案