微信小程序学习

知识点1:

在小程序里,想要引入其他页面里的公共代码,有两种方式:

1.

<include src="../header/header" />

这种引入方法是将一个页面全部引入另一个页面,不可以动态显示值

2.

被引入页面:
<template name='demo1'>
  <text>我是demo1{{text}}</text>
</template>


引入页面:
<import src="../footer/footer"></import>
<template is="demo1" data="{{text:'我是text'}}"></template>

这种引入方法是将一个页面中的template引入另一个页面,可以动态显示值

另外,wxss也需要引入进来,

在引入页面的wxss中:

@import"../header/header.wxss";

知识点2:

在小程序里,想要跳转到指定页面:

1.调用微信的navigateTo:(可返回)

原跳转页面:
wx.navigateTo({
  url: 'test?id=1'  //要传递的值
})
要跳转到的页面:
onLoad: function(option){
    console.log(option.id) //传递过来的值
  }

2.调用微信的redirectTo(不可返回)

wx.redirectTo({
  url: 'test?id=1'
})

3.调用微信的navigator (加了redirect属性后在当前页打开,不可后退)

<navigator url="/page/navigate/navigate?title=hello">跳转到新页面</navigator>
 <navigator url="../../redirect/redirect/redirect?title=redirect" open-type="redirect" >在当前页打开</navigator>

(***元素的自定义属性传递值:)

触发元素:
<text data-msg="我是msg" bindtap='handleclick'>取值</text>

js:
e.target.dataset.msg 可以直接拿到属性的值

知识点3:

input标签的输入取值:

<input bindinput='handlechange' placeholder='请输入……'></input>

handlechange(event){
    console.log(event.detail.value);
  }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值