写静态HTML的时候是有预览效果的,使用了vue动态加载就没有效果了,
网上的说法是动态生成的没有激活事件:ZUI(BootStrap)动态插入HTMl所创建的data-toggle事件初始化方法
处理方法是:
$(“.cards”).find(‘.card’).eq(0).find(‘a’).eq(0).lightBox(); popover同理:$(“.cards”).find(‘.card’).eq(0).find(‘a’).eq(0).popover();
这边优化了下:加载完列表时触发lightBox
watch 下item的加载完成
var app = new Vue({ el: '#app', data: { items: [ {"id":1} ], page: { "index": 1, "total": 0, "pagesize": 2 } }, methods: { indexs:function(){ axios .get('mock/ajax-form-list.json') .then(response => { // console.log(response); this.items = response.data.result.list this.page = response.data.result.page }) .catch(function (error) { // 请求失败处理 console.log(error); }); } }, watch:{ items: function() { this.$nextTick(function(){ /*现在数据已经渲染完毕*/ $('img.cardimg').lightBox({ caption: '图片说明' }); console.log("load completed") }) } }, created(){ //自动加载indexs方法 this.indexs(); console.log("created completed") }, mounted(){ console.log("mounted completed") } });
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。