简体   繁体   English

nuxt.js-$(…).slider不是函数

[英]nuxt.js - $(…).slider is not a function

I want to use jquery in nuxt.js, I added jquery in nuxt.config.js like this: 我想在nuxt.js中使用jquery,我在nuxt.config.js中添加了jquery,如下所示:

build: {
    plugins: [
        new webpack.ProvidePlugin({
            '$': 'jquery',
            '_': 'lodash'
        })
    ]
}

and then I used jquery code in in my template and I put jquery code in mounted() to avoid "document is not defined" error: 然后在模板中使用jquery代码,然后将jquery代码放入mount()以避免“未定义文档”错误:

mounted: () => {
    $("#volume").slider({
        min: 0,
        max: 100,
        value: 0,
        range: "min",
        slide: function(event, ui) {
            setVolume(ui.value / 100);
        }
    });
    ....
}

but when I run this, I get $(...).slider is not a function in browser. 但是当我运行它时,我得到$(...).slider is not a function浏览器中$(...).slider is not a function Is there anything special I should do to get it to work in nuxt.js? 为了使其在nuxt.js中起作用,我应该做些什么特别的事情?

$().slider is a jQuery UI function. $()。slider是一个jQuery UI函数。 You also need to add jquery-ui to your project. 您还需要将jquery-ui添加到您的项目中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM