微信小程序开发笔记-函数

小程序配置 app.json
工具配置 project.config.json
页面配置 page.json
WXML 模板
JS 逻辑交互

app======================================================
app.js
    app() 注册一个小程序,只会调用一次
pages=====================================================
json的值=====================    
    navigationBarTitleText   顶部导航文字

wxml的模板==================
    <view>模块
    <text>文本 
    <image>图片
    <button>按钮
    <navigator url='../mypage/mypage' class='nav-text'>跳转的我的页面</navigator>页面跳转
    <button bindtap='tomypage' size='mini' type='primary'>跳转到我的页面</button>
            button:按钮
            bindtap:调用tomypage函数
            type:按钮样式

    <view class='li' wx:for="{{arr}}" wx:key="{{index}}">{{index}}:{{item}} {{item.color}}</view>
            wx:for: 循环数组            
            index:索引
            item:     元素值
            wx:key:    必填,否则报空指针
item.color:     元素中的属性

    <view class='item' wx:if="{{bShow}}"></view>
       wx:if 后面跟true,false

js的函数====================
      page() 注册一个页面
      //事件跳转到我的页面
      tomypage(){
        wx.navigateTo({
          url: '../mypage/mypage',
        })
      },

      //字段值更换
      changeMotto(){
        this.setData({
            motto:'aaa' + Date.now()
        });
      }
  
wxss的样式=================
    /*颜色,字体大小, 宽,高,背景,边框,浮动,间距,下边线 */
    .nav-text{
        color:aqua;
        font-size: 15px;
        width: 100px;
        height: 100px;
        background: red;
        border:1px solid #000;
        float: left;
        margin:10px;
        border-bottom: 1px dashed #000;
    }

common.js=================
    导出模块:
        module.exports.x=x
        exports.x=x
        
        module.exports={};
    使用:
        let co=require(模块路径);
扫一扫================================================
调用微信扫一扫能力,只需要:
wx.scanCode({
  success: (res) => {
    console.log(res)
  }
})

猜你喜欢

转载自blog.csdn.net/m0_37771398/article/details/89133294
今日推荐