javascript - vue中如何使用mobiscroll插件
问题描述
项目中需要将以前的jquery换成vue实现,之前的代码使用mobiscroll实现的,现在把之前的插件js都放在了index.html下面了,但是在首页却总是报Error in mounted hook: 'ReferenceError: mobiscroll is not defined'。是该插件不支持vue吗?总是报mobiscroll这个方法不存在,我用webstrom确实能点到插件里面的,所以依赖不是问题。js插件是放在index.html下引入的,没有用npm报错代码是: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('<span></span>') $('#userinfo').find('input[name=’sex’]').val($(this).data('sex'));}) },
问题解答
回答1:npm install exports-loader //下载webpack loader插件
将mobiscroll插件(包括css)放在common下的js文件夹中
在需要调用Mobiscroll的组件中调用
require(’exports?$=jQuery!../../Common/js/mobiscroll.js’)
相关文章:
1. 问题Unknown column ’’ in ’where clause’2. angular.js - 如何控制ngrepeat输出的个数3. html - vue项目中用到了elementUI问题4. javascript - 在使用 vue.js element ui的时候 怎么样保留table翻页后check的值?5. mysql_replication - mysql读写分离时如果单台写库也无法满足性能怎么解决6. javascript - vue组件通过eventBus通信时,报错a.$on is not a function7. css3 - css怎么实现图片环绕的效果8. linux - ubuntu 命令行中文 显示菱形,期望通过引入字体解决而不是zhcon这种方式9. ionic 项目 ionic build android -release 打包时报错10. python - 如何用pandas处理分钟数据变成小时线?

网公网安备