微信小程序常见面试题
小程序的登录需要请求几次?
- 请求wx.login,返回code
- 发送code,返回openid+sessionKey
- 请求getuserinfo(用户信息)
小程序怎样使用自定义组件?
首先需要在 json 文件中进行自定义组件声明
{
"component":true
}
然后在自定义组件的 js 文件中,需要使用 Component()来注册组件;
使用时在页面的 json文件中进行引用声明。此时需要提供每个自定义组件的标签名和对应的自定义组件文件路径:
{
"usingComponents":{
"component-tag-name":"path/to/the/custom/component"
}
}