I am using webpack and tried to include the package but failed with many trails with different combinations. Please help. Appericated.
Dick Chan
Webpack configuration:
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
externals: {
"vue-grid-layout" : "VueGridLayout"
},
module: {
rules: [
{
test: /.vue$/,
loader: 'vue-loader',
options: {
loaders: {
}
// other vue-loader options go here
}
},
// {
// test: /.css$/,
// loader: 'style-loader!css-loader'
// },
{
test: /.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
// plugins: [
// new webpack.ProvidePlugin({
// $: 'vue-grid-layout',
// VueGridLayout: 'vue-grid-layout'
// }),
// ],
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
},
devServer: {
historyApiFallback: true,
noInfo: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}
main.js
import Vue from 'vue'
import VueMaterial from 'vue-material'
// import 'vue-material/dist/vue-material.css'
import VueRouter from 'vue-router'
import App from './App.vue'
import Users from './Users.vue'
import Home from './Home.vue'
import VueGridLayout from 'vue-grid-layout'
Vue.use(VueMaterial)
Vue.use(VueRouter)
Vue.use(VueGridLayout)
const routes = [
{ path: '/users', component: Users },
{ path: '/', component: Home },
]
const router = new VueRouter({
routes: routes
})
Vue.material.registerTheme({
default: {
primary: {
color: 'light-green',
hue: 700
},
accent: 'red'
},
blue: {
primary: 'blue',
accent: 'pink'
},
orange: {
primary: 'orange',
accent: 'purple'
},
green: {
primary: 'green',
accent: 'light-green'
}
})
var testLayout = [
{"x":0,"y":0,"w":2,"h":2,"i":"0"},
{"x":2,"y":0,"w":2,"h":4,"i":"1"},
{"x":4,"y":0,"w":2,"h":5,"i":"2"},
{"x":6,"y":0,"w":2,"h":3,"i":"3"},
{"x":8,"y":0,"w":2,"h":3,"i":"4"},
{"x":10,"y":0,"w":2,"h":3,"i":"5"},
{"x":0,"y":5,"w":2,"h":5,"i":"6"},
{"x":2,"y":5,"w":2,"h":5,"i":"7"},
{"x":4,"y":5,"w":2,"h":5,"i":"8"},
{"x":6,"y":4,"w":2,"h":4,"i":"9"},
{"x":8,"y":4,"w":2,"h":4,"i":"10"},
{"x":10,"y":4,"w":2,"h":4,"i":"11"},
{"x":0,"y":10,"w":2,"h":5,"i":"12"},
{"x":2,"y":10,"w":2,"h":5,"i":"13"},
{"x":4,"y":8,"w":2,"h":4,"i":"14"},
{"x":6,"y":8,"w":2,"h":4,"i":"15"},
{"x":8,"y":10,"w":2,"h":5,"i":"16"},
{"x":10,"y":4,"w":2,"h":2,"i":"17"},
{"x":0,"y":9,"w":2,"h":3,"i":"18"},
{"x":2,"y":6,"w":2,"h":2,"i":"19"}
];
Vue.config.debug = true;
Vue.config.devtools = true;
var GridLayout = VueGridLayout.GridLayout;
var GridItem = VueGridLayout.GridItem;
new Vue({
el: '#app',
components: {
GridLayout,
GridItem,
},
data: {
layout: testLayout,
draggable: true,
resizable: true,
index: 0
},
router,
render: h => h(App)
})
Home.vue
Displayed as
[x, y, w, h]
:
{{item.i}}: [{{item.x}}, {{item.y}}, {{item.w}}, {{item.h}}]
Draggable
Resizable
{{item.i}}
Error Message
3(unknown) [Vue warn]: Property or method "draggable" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
(found in at /Users/dickhfchan/vue-webpack/vue-routing/src/Home.vue)
warn
3(unknown) [Vue warn]: Property or method "resizable" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
(found in at /Users/dickhfchan/vue-webpack/vue-routing/src/Home.vue)
warn
(unknown) [Vue warn]: Property or method "layout" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
(found in at /Users/dickhfchan/vue-webpack/vue-routing/src/Home.vue)
warn
(unknown) [Vue warn]: Property or method "draggable" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
(found in at /Users/dickhfchan/vue-webpack/vue-routing/src/Home.vue)
warn
(unknown) [Vue warn]: Property or method "resizable" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
(found in at /Users/dickhfchan/vue-webpack/vue-routing/src/Home.vue)
warn
(unknown) [Vue warn]: Property or method "layout" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
(found in at /Users/dickhfchan/vue-webpack/vue-routing/src/Home.vue)
warn
(unknown) [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in at /Users/dickhfchan/vue-webpack/vue-routing/src/Home.vue)
warn
(unknown) You are running Vue in development mode.