Comments (19)
For me it was:
import draggable from "@/vuedraggable"
in the demo file, the @
is mapped to my resources folder, I don't know why this is in the demo. It just should be import draggable from 'vuedraggable'
.
from vue.draggable.
Hello @lzxb , could you provide more info? Which version of vue draggable, which OS?
It seems to me that you are trying to install an old version.
I just tested version 2.3.1 here, and it works fine with webpack.
from vue.draggable.
mac
{
"name": "app-weixin",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "node server",
"dev:dist": "cross-env NODE_ENV=production gulp devDist",
"dev:test": "gulp devTest"
},
"author": "",
"license": "ISC",
"devDependencies": {
"autoprefixer-loader": "^3.2.0",
"babel-core": "^6.17.0",
"babel-helper-vue-jsx-merge-props": "^2.0.1",
"babel-loader": "^6.2.5",
"babel-plugin-syntax-jsx": "^6.13.0",
"babel-plugin-transform-object-assign": "^6.8.0",
"babel-plugin-transform-vue-jsx": "^3.1.0",
"babel-preset-es2015": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"cross-env": "^3.1.1",
"css-loader": "^0.25.0",
"del": "^2.2.2",
"file-loader": "^0.9.0",
"gulp": "^3.9.1",
"gulp-sftp": "^0.1.5",
"html-webpack-plugin": "^2.22.0",
"less": "^2.7.1",
"less-loader": "^2.2.3",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"vue-loader": "^9.5.1",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.16.1"
},
"dependencies": {
"flex.css": "^1.1.4",
"is": "^3.1.0",
"jquery": "^3.1.1",
"vue": "^2.0.1",
"vue-router": "^2.0.0",
"vuex": "^2.0.0"
}
}
from vue.draggable.
you should be install vue,draggable using npm: npm install vuedraggable --save-dev
.
After instalation, your package file will look like:
"dependencies": { "vue": "^2.0.1", "vuedraggable": "^2.3.1" },
from vue.draggable.
ok
from vue.draggable.
Did it solve your problem?
from vue.draggable.
No, found a very strange bug
from vue.draggable.
I write an example for you to see, wait a minute.
from vue.draggable.
from vue.draggable.
- You should as in the example export like this:
import draggable from 'vuedraggable'
export default {
components: {
draggable
},
-
Could you show me the corresponding package.json?
-
Dis you modify vuedraggable. I see some comented lines in your p´rint screen.
from vue.draggable.
Did you check that as webpack configuration you have:
resolve: { fallback: [path.join(__dirname, '../node_modules')],
You should try using vue-cli template as a reference,
from vue.draggable.
Invalid configuration
from vue.draggable.
This can be
if (typeof exports == "object") {
var Sortable = require("sortablejs");
module.exports = buildDraggable(Sortable);
} else if (typeof define == "function" && define.amd) {
define(['sortablejs'], function (Sortable) {
return buildDraggable(Sortable);
});
} else if (window && window.Vue && window.Sortable) {
var draggable = buildDraggable(window.Sortable);
Vue.component('draggable', draggable);
}
from vue.draggable.
I guess you have a problem in your environment/webpack configuration. Please use official vue-cli to set-up your webpack environment and install vuedraggbale after.
from vue.draggable.
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const config = require('./config/')
const IS_ENV = process.env.NODE_ENV == 'production'
var plugins = []
if (IS_ENV) { //生产环境
plugins.push(new webpack.DefinePlugin({ //编译成生产版本
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}))
plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}))
}
plugins.push(
new HtmlWebpackPlugin({ //根据模板插入css/js等生成最终HTML
filename: './index.html', //生成的html存放路径,相对于 path
template: './src/template/index.html', //html模板路径
hash: process.env.NODE_ENV != 'production' //生产版本时,会打包成离线应用程序,不需要添加hash,否则会造成无法离线缓存的bug
})
)
module.exports = {
entry: ['./src/main.js'], //编译入口文件
output: {
publicPath: config.publicPath, //服务器的路径
path: __dirname + config.publicPath, //编译到app目录
filename: '[name].js' //编译后的文件名
},
module: {
loaders: [
{
test: /\.js(x)*$/,
exclude: /^node_modules$/,
loader: 'babel'
},
{
test: /\.vue$/,
exclude: /^node_modules$/,
loader: 'vue'
},
{
test: /\.css/,
exclude: /^node_modules$/,
loader: 'style-loader!css-loader'
},
{
test: /\.less/,
exclude: /^node_modules$/,
loader: `style-loader!css-loader!autoprefixer-loader?{
browsers: [
'ie >= 8',
'ie_mob >= 10',
'ff >= 26',
'chrome >= 30',
'safari >= 6',
'opera >= 23',
'ios >= 5',
'android >= 2.3',
'bb >= 10'
]
}!less-loader`
},
{
test: /\.(png|jpg)$/,
exclude: /^node_modules$/,
loader: 'url?limit=2000&name=[name].[ext]' //注意后面那个limit的参数,当你图片大小小于这个限制的时候,会自动启用base64编码图片
},
{
test: /\.(eot|woff|svg|ttf|woff2|gif|appcache)(\?|$)/,
exclude: /^node_modules$/,
loader: 'file-loader?name=[name].[ext]'
}
]
},
plugins,
resolve: {
extensions: ['', '.js', '.vue', '.jsx'], //后缀名自动补全
fallback: [path.join(__dirname, 'node_modules')],
alias: {
vue: 'vue/dist/vue.js',
util: path.resolve('src/util/index.js'), //常用工具方法
mixinTableList: path.resolve('src/util/mixinTableList.js'), //表格列表获取数据
mixinTableListCheckbox: path.resolve('src/util/mixinTableListCheckbox.js'), //表格列表全选操作
mixinTableListHandleIds: path.resolve('src/util/mixinTableListHandleIds.js'), //表格列表批量删除操作
mixinTableListLayer: path.resolve('src/util/mixinTableListLayer.js'), //表格列表的弹层操作
}
},
}
from vue.draggable.
@lzxb , As I mentioned in my last comment, please use official vue-cli to set-up your webpack environment and install vuedraggbale after using npm install option:
vue init webpack my-project
cd my-project
npm install
npm install vuedraggable --save
If you have issue after this installation, I will investigate.
If this works, please try to adjust you environment then.
Everything indicates that this is a configuration issue , but unfortunatelly I do not have time to investigate more.
from vue.draggable.
I understand, but unfortunately I did not use the official vue-cli
from vue.draggable.
Some tips:
- be sutre to install vue draggble using npm install vuedraggable --save
- check that npm download sortablejs in the node module folder?
- Depeneding on your environement you use
resolve: {
alias:{
'sortablejs' : 'myweirdpáth'
from vue.draggable.
666, ok, solve
from vue.draggable.
Related Issues (20)
- 拖动到窗口下边缘的时候怎么触发滚动?
- Has anyone found a solution for Max depth nesting with vue-draggable? If there is any parameter for setting the maximum depth in the nested solution?
- 判断被拖拽元素是否在目标区域内并阻止拖拽
- TypeError: Cannot read properties of undefined (reading 'class')
- Draggable preventing scroll behavior HOT 1
- [feature request] typing for `change` event
- Has this project stopped updating and maintaining
- New draggable under maintenance HOT 1
- Incorrect display of the sheet after dragend HOT 2
- npm i -S vuedraggable 直接报错
- VueDraggable only @choose @unchoose events only getting triggered in vue2.7.15 version
- Please set the `latest` npm tag to v4
- Not working with Socket.io
- How to disable draggable in vue draggable HOT 1
- How to import nested-draggable component ? Vue2
- Triggering drag and drop programmatically
- Missing required prop: "itemKey"
- how to lock vuedraggable for specific array nested level
- Nested Draggable Input with v-model automatically blurs
- Incorrect Visual Representation After Transferring All Items Between Groups
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue.draggable.