e 9 meses atrás
pai
commit
75ae5006ab

+ 30 - 2
小程序/pages/home/home.js

@@ -5,14 +5,42 @@ Page({
    * 页面的初始数据
    */
   data: {
-
+    week:"二",
+    obj:{
+      name:"小郑",
+      age: 18
+    },
+    arr:[
+      {
+        name:"小红",
+        age: 10
+      },
+      {
+        name:"小黄",
+        age: 20
+      },
+      {
+        name:"小蓝",
+        age: 30
+      },
+    ]
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
-
+    setTimeout(()=>{
+      // 原生小程序中
+      // this.setData({})
+      // obj.age = 29;
+      this.setData({
+        obj:{
+          name:"小郑",
+          age: 29
+        }
+      })
+    },4000)
   },
 
   /**

+ 27 - 1
小程序/pages/home/home.wxml

@@ -1,2 +1,28 @@
 <!--pages/home/home.wxml-->
-<text>首页</text>
+<view>
+  今天星期{{week}}
+  <text>
+    我叫{{obj.name}},今年{{obj.age}}
+  </text>
+</view>
+<!-- 列表渲染 -->
+<!-- v-for= 'item in arr' :key=index -->
+<view wx:for="{{arr}}" wx:for-item="item" wx:key="index">
+  <view>
+    {{index+1}}--我叫{{item.name}}--今年{{item.age}}
+  </view>
+</view>
+<!-- 条件渲染 -->
+<view wx:if="{{obj.age < 18}}">未成年</view>
+<view wx:elif="{{obj.age == 18}}">刚成年</view>
+<view wx:else="{{obj.age > 18}}">成年人</view>
+<!-- 内置组件 -->
+<button>哈哈哈</button>
+<input type="text" class="inp"/>
+<!-- 引用 -->
+<template name="news">
+  <view>今天天气真好,今天是星期{{hoilday}}</view>
+</template>
+<template name="aa">
+  <view>哈哈哈哈哈</view>
+</template>

+ 6 - 1
小程序/pages/home/home.wxss

@@ -1 +1,6 @@
-/* pages/home/home.wxss */
+/* pages/home/home.wxss */
+.inp {
+  width: 200rpx;
+  height: 50rpx;
+  border: 1rpx solid #f00;
+}

+ 2 - 1
小程序/pages/list/list.wxml

@@ -1,2 +1,3 @@
 <!--pages/list/list.wxml-->
-<text>列表</text>
+<text>列表</text>
+<include src="../home/home" />

+ 4 - 1
小程序/pages/my/my.wxml

@@ -1,2 +1,5 @@
 <!--pages/my/my.wxml-->
-<text>我的</text>
+<text>我的</text>
+<!-- 使用:引用方法 -->
+<import src="../home/home"/>
+<template is="news" data="{{hoilday:'三'}}"/>

+ 7 - 0
小程序/project.private.config.json

@@ -7,6 +7,13 @@
   "condition": {
     "miniprogram": {
       "list": [
+        {
+          "name": "",
+          "pathName": "pages/home/home",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        },
         {
           "name": "",
           "pathName": "pages/my/my",