问题描述:
a.wxml 内容
<import src="b.wxml" />
<template is="b" data="{{id}}"></template>
b.wxml 内容
<template name="b">
<view>ID是 {{ id }}</view>
</template>
b.js 内容
Page({
...
})
希望实现:我可以在b.js里面获取到 a.wxml 传给 b.wxml 的 id, 然后通过 id 进行其他操作,请问怎么实现?
问题描述:
a.wxml 内容
<import src="b.wxml" />
<template is="b" data="{{id}}"></template>
b.wxml 内容
<template name="b">
<view>ID是 {{ id }}</view>
</template>
b.js 内容
Page({
...
})
希望实现:我可以在b.js里面获取到 a.wxml 传给 b.wxml 的 id, 然后通过 id 进行其他操作,请问怎么实现?
2 个回答
模板里的事情事件可以写在引入模板的js里,你的这个需求可以用父子组件的形式去做
利用父子组件之间的通信
不要用模板,用组件。