【发布时间】:2020-01-31 03:55:39
【问题描述】:
我正在构建一个简单的 VueJs 组件,它根本不会在 IE 10 中呈现。
背景:Vue 组件是一个公司事件列表,支持基本的过滤和排序。不幸的是,我必须支持IE10。我没有使用 babel,但尝试使用它来解决这个问题 - 没有效果
我得到的错误是'city' is undefined。 IE10 是唯一遇到此问题的浏览器。
Here's a CodePen 只是相关代码。我添加了 cmets 以澄清发生了什么。这里只是 JS(请参阅 CodePen 了解完整代码和更好的上下文):
/* Server rendered data */
var events = [{
path: "events/residuals-biosolids",
name: "Residuals & Biosolids Conference",
sortDate: "1536165900000",
startDate: "4 September 2018",
endDate: "5 October 2018",
displayDate: "September 4 - October 5, 2018",
state: "WI",
city: "Milwaukee",
booth: "342",
featuredImg: "https://cdn2.hubspot.net/hubfs/4299619/event%20thumb.png"
}, {
path: "events/bio-expo",
name: "Biosolid Expo",
sortDate: "1548979200000",
startDate: "6 February 2019",
endDate: "5 March 2019",
displayDate: "February 6 - March 5, 2019",
state: "MN",
city: "Eagan",
booth: "12",
featuredImg: ""
}, {
path: "events/world-ag-expo",
name: "World AG Expo",
sortDate: "1549670400000",
startDate: "7 February 2019",
endDate: "2 February 2019",
displayDate: "February 7 - 2, 2019",
state: "CA",
city: "Tulare",
booth: "3815",
featuredImg: ""
}];
var eventsDesc = [{
path: "world-ag-expo",
name: "World AG Expo",
sortDate: "1549670400000",
startDate: "7 February 2019",
endDate: "2 February 2019",
displayDate: "February 7 - 2, 2019",
state: "CA",
city: "Tulare",
booth: "3815",
featuredImg: ""
}, {
path: "bio-expo",
name: "Biosolid Expo",
sortDate: "1548979200000",
startDate: "6 February 2019",
endDate: "5 March 2019",
displayDate: "February 6 - March 5, 2019",
state: "MN",
city: "Eagan",
booth: "12",
featuredImg: ""
}, {
path: "residuals-biosolids",
name: "Residuals & Biosolids Conference",
sortDate: "1536165900000",
startDate: "4 September 2018",
endDate: "5 October 2018",
displayDate: "September 4 - October 5, 2018",
state: "WI",
city: "Milwaukee",
booth: "342",
featuredImg: "https://cdn2.hubspot.net/hub/4299619/hubfs/event%20thumb.png?width=760&name=event%20thumb.png"
}];
var selectedStates = ["CA", "MN", "WI", ];
var selectedCities = ["Eagan", "Milwaukee", "Tulare", ];
/*
Vue code below
*/
var app = new Vue({
el: "#sg-events-wrapper",
data: {
message: "Hello Vue!",
dateOrder: "ascending",
selectedCity:"none",
selectedState:"none",
/*the data below is pulled from the script tag in the page.*/
eventCities:selectedCities,
eventStates:selectedStates,
eventList: events,
eventListDesc:eventsDesc,
},
computed: {
eventsSorted:function(){
/*chooses which server generated list to use for rendering events*/
if(this.dateOrder=="ascending"){
return this.eventList;
}
else{
return this.eventListDesc;
}
},
},
methods:{
/*handles the visual filtering when someone sets city and or state*/
isInStateAndCity:function(eventsCity,eventsState){
var citiesMatch;
var statesMatch;
if(eventsCity == this.selectedCity || this.selectedCity=="none"){
citiesMatch = true;
}else{
citiesMatch = false;
}
if(eventsState == this.selectedState ||this.selectedState=="none"){
statesMatch = true;
}else{
statesMatch = false;
}
if(citiesMatch && statesMatch){
return true;
}else{
return false;
}
}
}
});
我尝试过的故障排除步骤:
- 使用 babel,虽然我的代码最初不是这样写的。
- 我使用了 babel-polyfill - 似乎没有效果。
- 我尝试将正文中脚本标记中的 js 放入主 JS 文件中,以查看在 HTML 中的代码之前由于某种原因加载 js 文件是否存在问题。没有效果。
我认为可能是导致问题的原因:IE10 不喜欢像我正在做的那样将属性值分配给对象。不确定这一点。这只是一个猜测,我想不出其他方法。
IE 10 控制台错误和 CodePen 渲染失败的屏幕截图,以防万一。
如果您有任何想法但无法进行测试:我可以测试任何更改,并在出现错误时将我看到的内容和控制台的记录发回。
【问题讨论】:
-
发布您的
.babelrc。 -
@connexo 我实际上并没有使用 babel,我尝试将其作为故障排除步骤,但没有效果。我没有 babelrc 文件。我会澄清我的帖子以说明这一点。
-
你能给codepen.io/connexo/pen/oPRGNp?editors=1111一个IE 10的机会吗?
-
结果没有变化spin.d.pr/FZXbeU(你的笔的IE10截图)谢谢你的尝试!
标签: javascript internet-explorer vue.js internet-explorer-10