模板引用
模板引用
提高模板复用性;
定义模板
<template name="A"> <text> A template </text> </template>
引入模板
- Import 可以在该文件中使用目标文件定义的
template
<import src="/pages/templates/a.wxml" />
<template is="a"></template>
include
可以将目标文件除了 template
外的整个代码引入,相当于是拷贝到 include
位置
<include src="/pages/templates/b.wxml" />
网络请求
wx.request({
url: 'test.php', //仅为示例,并非真实的接口地址
data: {
x: '',
y: ''
},
header: {
'content-type': 'application/json' // 默认值
},
success (res) {
console.log(res.data)
}
})