vue.js 版本
v1.0.17
在ios7或android 4.1 ~ android 5.1 默认浏览器中使用动态组件,会使得子组件同时执行并渲染
在ios9、android 最新版QQ浏览器 、PC版的Chrome浏览器中并不会同时执行,正常运行
css代码:
模板:
代码:
var A = Vue.extend({
data:function(){
return{
animation:''
}
},
template:'#component-a',
props:['Page'],
ready:function(){
_self = this;
setTimeout(function(){
_self.animation = 'move-animation';
_self.done();
},2000);
console.log('component-a ok');
},
methods:{
done:function() {
_self = this;
setTimeout(function(){
_self.Page = 'B'
},1000);
}
}
});
var B = Vue.extend({
data:function(){
return{
animation:''
}
},
template:'#component-b',
props:['Page'],
ready:function(){
_self = this;
setTimeout(function(){
_self.done();
},2000);
console.log('component-b ok');
},
methods:{
done:function(obj) {
this.animation = 'move-animation';
}
}
});
var app = new Vue({
el:'#app',
data:function(){
return {
animation:'',
isPage:''
}
},
props:['isPage'],
ready:function(){
_self = this;
setTimeout(function(){
_self.animation = 'move-animation';
_self.isPage = 'A'
},800);
},
components:{
'A':A,
'B':B
}
});
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
已找到问题所在,在没有用vue-cli 或Webpack 构建的项目中,直接在html或者javascript构建的
模板必须写成 :
否则,移动版浏览器(如:android 4.1 ~ android 5.1 原生浏览器、IOS7 原生浏览器、微信浏览器等)会同时执行组件并渲染,而不会像PC版那样调用到再执行