javascript - 如何在 vuejs 中使用光滑的滑块?
问题描述
我有一个需要滑块的组件文件。这就是我初始化光滑的方式。
import Slick from 'vue-slick'
components: { Slick },
data() {
return {
slickOptions: {
//options can be used from the plugin documentation
slidesToShow: 4,
infinite: true,
accessibility: true,
adaptiveHeight: false,
arrows: true,
dots: true,
draggable: true,
edgeFriction: 0.30,
swipe: true
}
}
},
// All slick methods can be used too, example here
methods: {
next() {
this.$refs.slick.next()
},
prev() {
this.$refs.slick.prev()
},
reInit() {
// Helpful if you have to deal with v-for to update dynamic lists
this.$refs.slick.reSlick()
}
}
但我得到多个错误。
1 - 错误解析错误:意外的令牌。
2 - 模块构建失败(来自 ./node_modules/babel-loader/lib/index.js):SyntaxError: Unexpected token (122:21)。
有人可以指导我如何在 vuejs 中使用 slick 吗?我以前在 jquery 中使用过 slick。
webpack.config.js 代码
module.exports = function (config, { isClient, isDev }) {
module: {
rules: [
{
test: /\.(woff|woff2|eot|ttf|svg)(\?.*$|$)/,
loader: 'file-loader'
}
]
}
build: {
extend (config, { isServer }) {
if (isServer) {
config.externals = [
require('webpack-node-externals')({
whitelist: [/^vue-slick/]
})
]
}
}
}
return config
}
解决方案
推荐阅读
- java - 创建 Jar 文件时抛出“java.lang.IllegalStateException:未设置位置”。例外
- c - 使用 Contiki OS 在 rpl 协议中实现多首选父级
- javascript - 如何使用 TinyMCE 显示格式化内容
- angular - 当“ng-select”点击“下拉菜单”之外的某个地方时没有关闭
- c# - C#如何在接受或拒绝Outlook约会时获取收件人添加的评论
- ruby-on-rails - 将 javascript 变量附加到 erb 标记中
- corda - 如何为每个节点加载不同的 UI
- javascript - 在所有情况下都使用 new Function() 不安全吗?
- java - 如何在 dropwizard 中禁用 cron 作业
- hyperledger - 将资产的特定属性导入另一个资产以在 Hyperledger Composer 中进行交易