在入口文件和组件中都引入了vue-awesome-mui
import Mui from 'vue-awesome-mui'
import 'vue-awesome-mui/mui/dist/css/mui.css'
import Vue from 'vue'
Vue.use(Mui)
但是在组件中这样写就会报错mui' is not defined
我的目的就是想在这个组件中监听是否使用了物理返回键
mounted () {
mui.init({
swipeBack: true
})
}
我在index.html里面也有监听返回键但是这是全局监听 我也想在某一个组件中监听用户是否使用了了返回键然后做一些操作 这个应该怎么办呢?
<script>
mui.init({
keyEventBind: {
backbutton: true
}
});
var first = null;
mui.back = function() {
if (!first) {
first = new Date().getTime();
history.go(-1);
setTimeout(function() {
first = null;
}, 1000);
} else {
if (new Date().getTime() - first < 1000) {
plus.runtime.quit();
}
}
};
</script>
你打包完成以后测试是没问题的,mui他是有加载的,本地环境调试貌似不行