99re热这里只有精品视频,7777色鬼xxxx欧美色妇,国产成人精品一区二三区在线观看,内射爽无广熟女亚洲,精品人妻av一区二区三区

單文件(SFC)模式定義組件

2020-12-29 10:53 更新

單文件(SFC)模式定義組件為avm.js支持的兩種編程模式之一,使用類Vue語法進行組件的定義,或者頁面的開發(fā),開發(fā)風格迎合Vue或者原生H5開發(fā)者。單文件方式定義的文件后綴名為.stml,因此也可以叫做stml組件。

使用stml定義一個組件 / 頁面

stml組件兼容Vue單文件組件(SFC)規(guī)范,使用語義化的Html模板及對象化js風格定義組件或頁面。stml最終被編譯為JS組件 / 頁面,渲染到不同終端。

定義組件:

// api-test.stml:


<template>  
    <view>
        <text>Hello APP</text>
    </view>  
</template>  
<script>
    export default {  
        name: 'api-test'
    }
</script>

添加樣式:

<template>  
    <view class='header'>
        <text>Hello APP</text>
    </view>  
</template>  
<script>
    export default {  
        name: 'api-test'
    }
</script>
<style scoped>
    .header{
        height: 45px;
    }
</style>

數(shù)據(jù)綁定:

<template>  
    <view class='header'>
        <text>{this.data.title}</text>
    </view>  
</template>  
<script>
    export default {  
        name: 'api-test',
        data(){
            return {
                title: 'Hello APP'
            }
        }
    }
</script>
<style scoped>
    .header{
        height: 45px;
    }
</style>

在其他組件或者頁面引用:

// app-index.stml:


<template>  
    <view class="app">  
        <img src="./assets/logo.png" />  
        <api-test></api-test> 
    </view>  
</template>
<script>
    import './components/api-test.stml'  

    
    export default {  
        name: 'app-index',  
        data: function () {  
            return {
                title: 'Hello APP'
            }
        }  
    }  
</script>  
<style>  
    .app {   
        text-align: center;  
        margin-top: 60px;  
    }  
</style>
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號