html 引入vue中动态拼接的html中点击方法触发

这篇博客探讨了在Vue.js中如何通过html拼接创建动态输入元素,并将自定义方法`showCurDate`与之关联。在`created`和`activated`钩子中,将方法绑定到全局`window`对象,确保页面加载时能调用该方法。这有助于在前端开发中实现动态交互和日期选择功能。
摘要由CSDN通过智能技术生成

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;
},

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值