e 1 vuosi sitten
vanhempi
commit
dd03988d17

+ 4 - 3
小程序/app.json

@@ -5,9 +5,10 @@
     "pages/my/my"
   ],
   "window": {
-    "navigationBarTextStyle": "black",
-    "navigationBarTitleText": "Weixin",
-    "navigationBarBackgroundColor": "#ffffff"
+    "navigationBarTextStyle": "white",
+    "navigationBarTitleText": "小程序",
+    "navigationBarBackgroundColor": "#ff0000",
+    "navigationStyle": "default"
   },
   "tabBar": {
     "custom": false,

+ 3 - 0
小程序/pages/car/car.json

@@ -1,3 +1,6 @@
 {
+  "navigationBarTextStyle": "white",
+  "navigationBarTitleText": "购物车",
+  "navigationBarBackgroundColor": "#ff00ff",
   "usingComponents": {}
 }

+ 3 - 1
小程序/pages/car/car.wxml

@@ -1,2 +1,4 @@
 <!--pages/car/car.wxml-->
-<text>购物车</text>
+<text>购物车</text>
+<import src="/pages/home/home"/>
+<template is="news" data="{{holiday:'假期'}}" />

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

@@ -5,14 +5,44 @@ Page({
    * 页面的初始数据
    */
   data: {
-
+    title: '首页1',
+    obj:{
+      name:"zs",
+      age: 15
+    },
+    arr:[
+      {
+        name:"小红",
+        age: 13,
+        address:"哈尔滨"
+      },
+      {
+        name:"小黄",
+        age: 23,
+        address:"天津"
+      },
+      {
+        name:"小蓝",
+        age: 33,
+        address:"郑州"
+      }
+    ]
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
-
+    setTimeout(()=>{
+      // 更新数据 this.setData({})
+      this.setData({
+        title: '新的页面',
+        obj:{
+          name:"李四",
+          age: 19
+        }
+      })
+    },3000)
   },
 
   /**

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

@@ -1,2 +1,35 @@
 <!--pages/home/home.wxml-->
-<text>首页</text>
+<view>
+  <!-- 数据渲染 -->
+  <view>{{title}}</view>
+  <view>
+    <view>姓名:{{obj.name}}</view>
+    <view>年龄:{{obj.age}}</view>
+  </view>
+  <!-- 列表渲染 -->
+  <!-- 
+    wx:for="{{list}}"
+    wx:key="index"
+    wx:for-item= "item"
+   -->
+  <!-- v-for=(item,index) in list -->
+  <view wx:for="{{arr}}" wx:key="index" wx:for-item="item">
+    <view>{{index+1}}--我叫{{item.name}}-今年{{item.age}}--来自{{item.address}}</view>
+  </view>
+  <!-- 条件渲染 -->
+  <!-- 
+    v-if
+    v-else
+    v-else-if
+   -->
+   <view wx:if="{{obj.age<=18}}">少年</view>
+   <view wx:elif="{{obj.age > 18}}">青年</view>
+   <view wx:else="{{obj.age > 28}}">老年</view>
+   <!-- 内置组件 -->
+   <button>按钮</button>
+   <input type="text" class="inp"/>
+   <!-- 引入:import -->
+   <template name="news">
+      <view>{{holiday}}</view>
+   </template>
+</view>

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

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

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

@@ -1,2 +1,3 @@
 <!--pages/my/my.wxml-->
-<text>我的</text>
+<text>我的</text>
+<include src="/pages/car/car"/>