zoukankan      html  css  js  c++  java
  • 微信小程序(一)

    一: 设置微信小程序底部导航栏

    我们找到项目根目录中的配置文件 app.json 加入如下配置信息

    "tabBar": {  
       "color": "#a9b7b7",  
       "selectedColor": "#11cd6e",  
       "borderStyle":"white",  
       "list": [{  
         "selectedIconPath": "images/111.png",  
         "iconPath": "images/11.png",  
         "pagePath": "pages/index/index",  
         "text": "首页"  
       }, {  
         "selectedIconPath": "images/221.png",  
         "iconPath": "images/22.png",  
         "pagePath": "pages/logs/logs",  
         "text": "日志"  
       }, {  
         "selectedIconPath": "images/331.png",  
         "iconPath": "images/33.png",  
         "pagePath": "pages/test/test",  
         "text": "用户"  
       }]  
     },  

    tabBar  指底部的 导航配置属性

    color  未选择时 底部导航文字的颜色

    selectedColor  选择时 底部导航文字的颜色

    borderStyle  底部导航边框的样色(注意 这里如果没有写入样式 会导致 导航框上边框会出现默认的浅灰色线条)

    list   导航配置数组

    selectedIconPath 选中时 图标路径

    iconPath 未选择时 图标路径

    pagePath 页面访问地址

    text  导航图标下方文字

    二: 微信小程序api接口之自定义菜单和相机

    看过微信api文档的人相比都了解

    wx.showActionSheet 和 wx.chooseImage 这俩个接口把,
    一个是自定义菜单功能,一个是图片功能, 具体参数我就不多说了,直接上代码
    chooseimage: function () {
        var that = this;
        wx.showActionSheet({
          itemList: ['从相册中选择', '拍照'],
          itemColor: "#CED63A",
          success: function (res) {
            if (!res.cancel) {
              if (res.tapIndex == 0) {
                that.chooseWxImage('album')
              } else if (res.tapIndex == 1) {
                that.chooseWxImage('camera')
              }
            }
          }
        })
    
      },
    
      chooseWxImage: function (type) {
        var that = this;
        wx.chooseImage({
          sizeType: ['original', 'compressed'],
          sourceType: [type],
          success: function (res) {
            console.log(res);
            that.setData({
              tempFilePaths: res.tempFilePaths[0],
            })
          }
        })
      }
    <button style="margin:30rpx;" bindtap="chooseimage">获取图片</button>
    <image src="{{tempFilePaths }}" catchTap="chooseImageTap" mode="aspectFit" style=" 100%; height: 450rpx" />

      

     效果图如下:

     

  • 相关阅读:
    C++常变量
    C++变量(C++变量定义、变量赋值、命名规则)
    463. Island Perimeter
    500. Keyboard Row
    811. Subdomain Visit Count
    901. Online Stock Span
    419. Battleships in a Board
    620. Not Boring Movies
    893. Groups of Special-Equivalent Strings
    575. Distribute Candies
  • 原文地址:https://www.cnblogs.com/LoveAndPeace/p/8310047.html
Copyright © 2011-2022 走看看