javascript - How to use mobiscroll plug-in in vue
巴扎黑
巴扎黑 2017-07-05 10:40:12
0
1
1401

In the project, the previous jquery needs to be replaced by vue. The previous code was implemented using mobiscroll. Now the previous plug-in js is placed under index.html, but the Error in mounted hook is always reported on the homepage. : "ReferenceError: mobiscroll is not defined". Does this plug-in not support vue?
It always reports that the mobiscroll method does not exist. I can indeed click on the plug-in using webstrom, so dependency is not a problem. The js plug-in is introduced under index.html. If npm is not used, the error code is: initPage(){

var currYear = (new Date()).getFullYear(); mobiscroll.settings $('#dataTime').mobiscroll().date({ theme : "android-holo", mode : "scroller", display : "bottom", lang : "zh", dateFormat : 'yyyy-mm-dd', defaultValue : new Date(new Date().setFullYear(currYear - 30)), startYear : currYear - 70, endYear : currYear + 10 }); $(".checkbox-span").click(function() { var idname = $(this).attr("id"); console.log(idname) if (idname == "xz-checkbox") { $(this).removeAttr("id"); $(".main-btn").attr("disabled", "disabled"); $(".main-btn").css("background", "#CCCCCC"); } else { $(this).attr("id", "xz-checkbox"); $(".main-btn").removeAttr("disabled"); $(".main-btn").css("background", ""); } }) $(".radio-p").click(function() { $(".radio-p").removeAttr("id"); $(".radio-span").html(""); $(this).attr("id", "xz-radio-p"); $(this).children(".radio-span").html("") $("#userinfo").find("input[name='sex']").val($(this).data("sex")); }) },
巴扎黑
巴扎黑

reply all (1)
黄舟
npm install exports-loader //下载webpack loader插件

Place the mobiscroll plug-in (including css) in the js folder under common

Call in the component that needs to call Mobiscroll

require('exports?$=jQuery!../../Common/js/mobiscroll.js')
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!