html 拼接的
html2 += "<span>"+card_txt2+":<input class=\"form-control time-s\" onclick='showCurDate()' id=\"user_key_id"+k+"\" name='time_1' value="+this.time+"></span>";
vue中:
methods:{
showCurDate(){
console.log('123')
},
}
连接两者,使页面能够加载该方法
created(){
console.log('created')
let _this = this
window.showCurDate= _this.showCurDate;
},
activated(){
console.log('activated')
let _this = this
window.showCurDate= _this.showCurDate;
},
这篇博客探讨了在Vue.js中如何通过html拼接创建动态输入元素,并将自定义方法`showCurDate`与之关联。在`created`和`activated`钩子中,将方法绑定到全局`window`对象,确保页面加载时能调用该方法。这有助于在前端开发中实现动态交互和日期选择功能。
850

被折叠的 条评论
为什么被折叠?



