<!DOCTYPE html>
<html>
<head>
<!-- 調整手機瀏覽器的螢幕解析度 -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<!-- 安裝字體及圖標 -->
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@4.x/css/materialdesignicons.min.css" rel="stylesheet">
<script src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
<!-- 安裝 Vuetify 樣式檔 -->
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet">
<!-- 安裝 Vue、vue-router 及 Vuetify -->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-router"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script>
</head>
<body>
<div id="app">
<v-app>
<v-content>
<v-container>
<!-- 用戶界面放在這裏 -->
</v-container>
</v-content>
</v-app>
</div>
<script>
// 啓動 Vue 及 Vuetify
var vm = new Vue({
el: '#app',
vuetify: new Vuetify(),
})
</script>
</body>
</html>
$\color{red}{後續程式範例,請利用下列程式模板,將程式碼填入到`<body></body>`區塊内,並以瀏覽器執行:}$
<!DOCTYPE html>
<html>
<head>
<!-- 調整手機瀏覽器的螢幕解析度 -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<!-- 安裝字體及圖標 -->
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@4.x/css/materialdesignicons.min.css" rel="stylesheet">
<script src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
<!-- 安裝 Vuetify 樣式檔 -->
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet">
<!-- 安裝 Vue、vue-router 及 Vuetify -->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-router"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script>
</head>
<body>
<!-- 本教材範例程式碼放在這裏 -->
</body>
</html>
使用 Vuetify 之前,必須先瞭解 Vue 的運作方式,以下為一簡單的範例:
<div id="app-1">
<v-app>
<v-content>
<v-container>
{{ helloMessage }}
</v-container>
</v-content>
</v-app>
</div>
<script>
new Vue({
el: '#app-1',
vuetify: new Vuetify(),
data: {
helloMessage: "Hello Vuetify"
}
})
</script>
Hello Vuetify
<div id="color-1" style="max-height:60px">
<v-app id="inspire">
<div class="red white--text">
紅底白字
</div>
<div class="black white--text">
黑底白字
</div>
<v-btn class="primary">
primary 色系按鈕
</v-btn>
</v-app>
</div>
<script>
var vm = new Vue({
el: '#color-1',
vuetify: new Vuetify(),
});
</script>
間距類別再設定元素的padding和margin,指令格式為{屬性}{方向}-{大小}。
<div id="pm-1" style="max-height:150px">
<v-app id="inspire">
<div>
<div class="py-2 black white--text text-center">
上下内距 padding:8px
</div>
<div class="my-2 black white--text text-center">
上下邊界 margin:8px
</div>
<div class="ma-auto pa-2 black white--text text-center" style="width:20%">
自動邊界、内距 8px
</div>
</div>
</v-app>
</div>
<script>
var vm = new Vue({
el: '#pm-1',
vuetify: new Vuetify(),
});
</script>