天天看點

uni-app 文法

  • v:on click
<button type="primary" v-on:click="clinkHandle(20, $event)">Button</button>
=> v-on = @
<button type="primary" @click="clinkHandle(20, $event)">Button</button>

methods: {
  clickHandle(num, e) {
    console.log(num, e);
  }
}      
  • template中通過{{資料}}顯示資料
  • 标簽屬性通過 :data-index = '資料' 顯示資料
<template>
    <view>
        <view>{{msg}}</view>
        <view :data-color="color">color</view>
    <view>{{person.name}}</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                msg: "this is a message",
                color: "red",
        person: {
                    name:"bill",
                    sex: "male"
                }
            }
        }
    }
</script>

<!--顯示結果-->
this is a message
color
bill