简体   繁体   中英

Website display an error SCRIPT1003: Expected ':' in IE 11

I used vue js 2 in one of website, and it turned out that there were some compatibility issue in earlier releases of internet explorer.

The error is

SCRIPT1003: Expected ':'

Here is the code

methods: {
          dataLoaded() {
            var ctx = this;
            if (window.location.hash) {
              var fragmentData = window.location.hash
                .replace("#", ""),
                .split("/");
              var categoryId = fragmentData[0];
              var categoryIndex = null;
              var offerIndex = parseInt(fragmentData[1]);
              var category = this.categories.filter(function(category, index) {
                if (category.id == categoryId) categoryIndex = index;
                return category.id == categoryId;
              })[0];
              if (category) {
                if (!category.loaded) {
                  this.loadOffers(category, function() {
                    if (category.offers[offerIndex]) {
                      ctx.showDetails(
                        category.offers[offerIndex],
                        categoryIndex,
                        offerIndex
                      );
                    }
                  });
                } else if (category.offers[offerIndex]) {
                  this.showDetails(
                    category.offers[offerIndex],
                    categoryIndex,
                    offerIndex
                  );
                }
              }
            }
          },

IE11不支持方法定义速记语法 495。您要么需要使用babel作为编译器,要么将数据加载的钩子更改为dataLoaded(): function() { //... }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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