第一章作业

在浏览器中输人网址“https://github.com/dunizb/wxapp-sCalc”,进人页面后下序简易计算器源码 demo,将其解压后使用微信小程序开发工具打开该项目,分析小页面结构及相关代码,对该小程序进行调试并运行。

 

第一步

 

在浏览器打开链接 https://github.com/dunizb/wxapp-sCalc 

f158219d0ef64182ab7eb9b13e8b9573.png

 第二步 

 

下载解压Download ZIP文件

a8d82f29a073402ea0bfc3b52a80493e.png

 第三步 

 

打开微信开发者工具app,导入项目

432dba645cd04dec92a33d3f4b68edd8.png

 导入成功后,运行效果

8451a9f5bbe54f25886c34fb6ee7d162.png

3d4651e65f744d55b3f79828c2b4b9ed.png 

 源代码如下 

//index.js

//获取应用实例

var app = getApp()

Page({

  data: {

    motto: '简易计算器☞',

    userInfo: {},

    defaultSize: 'default',

    disabled: false,

    iconType:'info_circle'

  },

  //事件处理函数

  bindViewTap: function() {

    wx.navigateTo({

      url: '../logs/logs'

    })

  },

  toCalc:function(){

    wx.navigateTo({

      url:'../calc/calc'

    })

  },

  onLoad: function () {

    console.log('onLoad');

    var that = this

   //调用应用实例的方法获取全局数据

    app.getUserInfo(function(userInfo){

      //更新数据

      that.setData({

        userInfo:userInfo

      })

    })

  }

})

 

<!--index.wxml-->

<view class="container">

  <view bindtap="bindViewTap" class="userinfo">

    <image class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image>

    

  </view>

  <view>

    <text class="userinfo-nickname">{{userInfo.nickName}}(Dunizb)</text>

  </view>

  <view class="usermotto">

    <!--<text class="user-motto">{{motto}}</text>-->

    <button type="default" size="{{primarySize}}" plain="{{plain}}" hover-class="button-hover"

        disabled="{{disabled}}" bindtap="toCalc"> {{motto}} </button>

  </view>

  <view>

    <navigator url="view" class="github" hover-class="navigator-hover">

      <icon type="{{iconType}}" class="icon" size="20"/>GitHub

    </navigator>

  </view>

</view>

 

/**index.wxss**/

.userinfo {

  /*display: flex;*/

  /*flex-direction: column;*/

  /*align-items: center;*/

  /*width:256rpx;*/

  /*height: 512rpx;*/

}

 

.userinfo-avatar {

  width: 128px;

  height: 128px;

  margin: 20rpx;

  border-radius: 50%;

}

 

.userinfo-nickname {

  color: #aaa;

  margin-top:80px;

}

 

.usermotto {

  margin-top: 35%;

}

 

/** 修改button默认的点击态样式类**/

.button-hover {

  background-color: red;

}

 

/** 修改默认的navigator点击态 **/

.navigator-hover {

    color:blue;

}

.github{

  color: green;

  font-size: 14px;

  text-align: center;

  margin-top: 5px;

}

.icon{

  vertical-align: middle;

  margin-right: 2px;

}

 

 

.github-info{

  padding: 10px 5px;

  font-size: 16px;

  font-family: "Microsoft YaHei";

  line-height: 20px;

  margin-bottom: 10px;

}

.url{

  color: blue;

}

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值