1. 什么是單文件組件:
把一個組件全部內容匯合到一個文件中,文件名字是以 .vue 結尾的就稱作 vue單文件組件
2. 最簡單使用
- 通過Vuecli創建一個空的項目並運行
- 創建單文件組件 src/component/01.單文件組件.vue
- src/main.js 文件中導入、注冊組件
- public/index.html 文件 使用 單文件組件
3. 組織結構
<template> 相關html標簽 </template> <script> export default { data, methods, computed, filters, created, …… } </script> <style> css樣式內容 </style>
