应对期末考试,对本学期《微信小程序开发实践》课程学习的内容进行复习,模拟题 2.


# 一、单项选择题 8 题 * 2=16 分

1. 下列选项中,关于微信小程序项目目录结构说法错误的是(C )。

A.pages 目录用于存放所有微信小程序的页面

B.app.wxss 文件定义了微信小程序项目的全局样式

C.sitemap.json 文件是微信小程序项目的全局配置文件

D.app.js 文件是微信小程序项目的入口文件

2. 下列选项中,app.json 文件中的 tabBar 配置项最多允许的页数为( C)。

A. 3 B. 4 C. 5 D. 6

3. 下列选项中,用于监听页面初次渲染成功的回调函数是(D )。

A. onHide B. onLoad C. onShow D. onReady

4. 下列选项中,将页面的 JS 文件中定义的数据绑定到页面上的语法是( A)。

A. {{ }} B. [] C. { } D. [[]]

5. 下列选项中,用于滑动选择某一个值的组件是(B )。

A. view

B. slider

C. input

D. audio

6. 下列选项中,关于 wx.getRecorderManager () 方法说法错误的是(D )。

A. start () 方法表示开始录音

B. pause () 方法表示暂停录音
C. resume () 方法表示继续录音

D. onError () 方法表示停止录音,点击开始录音后会从中断的地方接着继续录音

7. 下列选项中,用于实现非标签页之间的跳转的方法是(A )。

A. wx.navigateTo()

B. wx.navigate()

C. wx.navigatorTo()

D. wx.navigator()

8. 下列选项中,关于 marker 对象的属性说法错误的是(D )。

A. title 标注点名称

B. zIndex 表示显示层级

C. alpha 表示标注的透明度

D. userInfo 表示用户信息对象

# 二、填空题 7 题 * 2=14 分

1. 微信小程序项目中的______文件是全局配置文件。

2. 微信开发者工具中用于保存文件的快捷键是______。

3.image 组件的____属性用于设置图片的展示模式。

4.swiper 组件内部只可以放置____组件。

5. 在列表渲染中,使用____可以指定当前项的变量名。

6. 下载文件的 API 是 ___。 上传文件的 API 是 ____。

7.map 组件中地图视野发生变化时触发 ____ 事件。

8. 微信小程序通过 ____ 方法监听 WebSocket 接收到服务器的消息事件

# 三、判断题 8 题 * 2=16 分

1. 微信小程序项目中 app.js 文件是全局样式文件。(×

2. 微信小程序中样式文件为 WXSS 文件,只支持 rpx 一种尺寸单位。(×

3.video 组件专门用于播放音频。( ×

4. 所有绑定的数据都必须在 data 中进行初始化。(×

5. 通过调用 wx.previewImage () 方法可以使用选择媒体 API。( ×

6.openid 是微信小程序的唯一标识。( ×

7.animation.export () 方法每次调用后仍保留之前的动画操作。( ×

8. 同一个微信用户在 AppID 不同的微信小程序中的 openid 是不同的。(

# 四、程序题 6 题 * 4=24 分

1. 重点:掌握数据绑定,事件绑定,事件对象,this 关键字的使用以及 setData 方法的使用

image-20240623184225084

image-20240623184244138

<view class="container">
{{mes}}  //数据绑定{{}}
<view>
    // 绑定事件test(),bind:tap="test()"
    <button bind:tap="test()">按钮1-1</button>
    <button bind:tap="test">按钮1-2</button
    <button bindtap="test()">按钮2-1</button>
    <button bindtap="test">按钮2-2</button>
    <button bind:tap="changetext">按钮</button>
</view>
    
<view bind:tap="viewtap" id="out">out 
    <view id="inner" >inner</view>
</view>
    
<view wx:if="false">单独view1</view>
<view wx:elif="false">单独view2</view>
<view wx:else>单独view3</view>

image-20240623184458196

Page(
    data:{
    msg:'hello' // 数据绑定
    flag:1,
    hid:1,
},
num1:0,// 保存第 1 个数字
onLoad:function(){
    console.log(this.num1);
    console.log(this.data.msg);
    //console.log (this.msg);
    // 报错 
    console.log('onload');
},

onPullDownRefresh:function(){
    console.log('onPullDownRefresh');
    this.setData({ 
    msg:'hello world'
      //num1:42 无效
});
    console.log(this.num1);
},
test(){
    console.log('test');
},
test(){
    console.log('test');
},
viewtap:function(e){
    console.log(e);
    [console.log(___(补充触发事件组件的一些属性组合)+'/'+ ___(当前组件的一些属性组合));]{.red}
},
changetext(){
    this.setData({
        msg:'新标题'
    },this.test());
}

2.data-* 自定义属性,能够完成 data-* 自定义数据的设置与获取

image-20240623184700710

var hello = require('../../examplejs/hello')

Page({
    data:{
        [name:'初始值',]{.red}
        [age:0]{.red}
    },
    onLoad:function(){
        console.log(hello.msg);
    demo(e){
        this.setData({
            [name:e.target.dataset.name,]{.red}
            [age:e.target.dataset.infoAge]{.red}
        });
    }
})
<navigation-bar title="Weixin" back="false"color="black" background="#FFF">
</navigation-bar>
<scroll-view class="scrollarea" scroll-y type="list">
    <view class="container"
          Weixin
    <view>
    [<button bind:tap="demo" data-name="小程序"
            data-info-age="16">单击更新数据</button>]{.red}
    <view></view><view></view>
    </view>
    </view>
</scroll-view>

image-20240623184824204

numBtn:function(e) {
// 点击数字按钮,获取对应的数字,将其值赋给 num
    [var num = .target.dataset.val]{.red}
if(this.resultFlag){ 
    // 如果当前使用 = 计算了,则重置
    this.reset()
console.log('numbtn1',this.numChangeFlag,this.targetnum,this.numl,this.num2);
    if(this.numChangeFlag){
        this.numChangeFlag = false
        this.execFlag= true 
        // 代表已输入第 2 个数字
        this.data.num ='0’
        // 将 num 设为 0,避免数字进行拼接
        this.targetnum ='num2'
        // 将 target 切换到第 2 个数
    }

3. 重点:条件渲染

image-20240623184952264

<view wx:if="false">单独view1</view>
<view wx:elif="false">单独view2</view>
<view wx:else>单独view3</view>

<block wx:if="{{flag}}">
<view>第1个</view>
<view>第2个</view>
</block>

<text hidden="{{hid}}">文本hidden</text>
Page({
    data:{
        msg:'hello',
        [flag:1,]{.red}
        hid:1,
    }
num1:0,// 保存第 1 个数字
    onLoad:function(){
       console.log(this.num1);console.log(this.data.msg);
       //console.log (this.msg);   // 报错
       console.log('onload');
},
    onPullDownRefresh:function(){
        console.log('onPullDownRefresh');
        this.setData({
            msg:'hello world'
            //num1:42 无效
        });

4. 重点:列表渲染

image-20240623185011924

<view wx:for=""wx: key="*this">     
{{index}}{{item}}    
</view>

<viel>-----------</view>
<view wx:for="" wx:key="id">
{{index}}--{{item.message}}--{{item.id}}
</view>

<viel>-----------</view>
<view wx:for="{{list}}" wx:for-item="item2"
      wx : for-index="index2" wx:key="id">
      {{index2}}--{{item2.message}}--{{item.id}}
</view>

<view>--------</view>
<view wx:for="{{contract}}" wx:key="id">
  {{item.id}},{{item.name}},{{item.phone}}
</view>

<view>
<button bind:tap="sload">showLoading--持续1秒</button><button bind:tap="sload2">showLoading--持续3秒</button>
</view>
Page({
    data:{
        arr:['a
        list:[
             {message:'梅',id:1},
             {message:'兰',id: 2},
             {message:'竹',id:3},
             {message:'菊',id:4}
     },
     contract:[]
onLoad:function(){
    console.log('页面加载')
    this.getContract()
},
getContract:function(){
    wx.request({
        url:"http://127.0.0.1:3000/data2'
        method:'GET'
        data:{}

image-20240623185035258

sload(){
    wx.showLoading({
        title:'加载框'
        duration:1000 // 默认 1500 毫秒
    })
}
sload2(){
    wx.showLoading({
        title:'加载框'                   
        setTimeout(function(){
        wx.hideLoading()
    },3000)
},
stoast(){
    wx.showToast({
        title:'提示框'
        duration:3000,// 默认 1500 毫秒
        icon:"error"// 默认为 successicon:
    })
},
<view>
<button bind:tap="sload">showLoading--持续1秒</button><button bind:tap="sload2">showLoading--持续3秒</button><button bind:tap="stoast">wx.showToast</button>
</view>

# 五、简答题 2 题 * 15=30 分

1. 简述微信小程序如何实现上拉触底。

2. 简述 BackgroundAudioManager 实例的属性和方法。

更新于 阅读次数

请我喝[茶]~( ̄▽ ̄)~*

萝卜仔 微信支付

微信支付

萝卜仔 支付宝

支付宝