vue.js 直接<script>引用vue和vue-resource制作的页面在手机上怎么不能访问

后端是php页面部分用后端模板套 部分用vue,用后端模板的界面可以打开,用vue的都不行,怎么回事!!!

new Vue({
    el: '#app',
    data() {
        return {
            getSortListUrl:  "/Lease/Api/Product/getCategoryList",
            getCategoryInfoUrl:  '/Lease/Api/Product/getCategoryInfo',
            getProListByCatUrl: '/Lease/Api/Product/getProListByCat',
            sortlist: [],
            sortdetail: '',
            tabproductlist: [],
            productlist:[],
            selectItem: 0,
            sortid:'',
            page:1,
            indexid:'',
            categoryName:'',
            userId:1
        }
    },
    created() {
        this.getId();
        this.getSortList();
    },
    methods: {
        getId() {
            var that = this;
            var index = window.location.href.indexOf('/index');
            console.log(index);
            sessionStorage.setItem("user_id",that.userId);
            var user_id = sessionStorage.getItem("user_id");
            console.log(user_id);
            if(index == -1)
                that.indexid = '';
            else {
                var id = window.location.href.slice(index+7);
                that.indexid = id;
                console.log(that.indexid);
            }
        },
        getSortList() {
            var that = this;
            that.$http({
                    url: that.getSortListUrl,
                    methods: 'GET'
                })
                .then(function(response) {
                    var rtnData = response.data;
                    that.sortid = rtnData.data[0].id;
                    console.log(that.sortid);
                    if(rtnData.code == 200) {
                        that.sortlist = rtnData.data;
                        that.getCategoryInfo(this.sortid, 0);
                        if(that.indexid ==""){
                            that.getProListByCat(that.sortid,1,3);
                            console.log(that.indexid);
                        }else{
                            that.getProListByCat(that.indexid,1,3);
                        }
                    }
                }, function(error) {
                    //error
                    console.log(error);
                })
        },
阅读 5.8k
5 个回答

首先你可以先用谷歌的手机模拟器查看下能不能访问,可以把代码贴出来不然不好排查问题所在

可能代码有问题,是否使用了部分es6词法,谷歌对es6支持的比较好,而手机上的浏览器却不一定。你把代码贴出来给大家看看

把ES6的写法改成ES5的就行了

有以下原因:

  1. vue版本问题,1.0与2.0的api有很大改动:data用工厂方法适用于component,vue实例不需要;created替换成了mounted等等;

  2. 如果是单独引用vue.min.js类库,那么在没有引入babel的前提下es6语法无效;

data() {

    return { 删掉
    把es6语法删除
    
    改成
    var data = {};

data:data

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题