前導入門 2 — 平時比較少用的生命週期

<div id="app">{{ name }}</div>
let vm = new Vue({
	el: '#app',
	data: {
		name: 'aka allen'
	}
})

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/7860b4cd-3161-4b50-9bda-736b2f02cb5a/Untitled.png

let vm = new Vue({
	template: `
		<div id="replace"> 
			<span> {{ name }} </span>
		</div>
	`,
  data: {
    name: 'aka allen'
  }
})

再往下看生命週期,有 template 就會將他丟進 render 函式編譯,沒有 template ,就會抓元素的 outerHTML 來做為 template 編譯並渲染掛載。

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/14ebde70-ce78-4487-a9a4-612d801c612a/Untitled.png

https://codepen.io/fiftybillionHuang/pen/NWNvJKV

前導入門 3 — 開始解說組件 ( Component )

全域組件 ( 我都叫他大組件 )

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>鐵人賽Vue-CLI-30-01</title>
</head>
<body>
  <div id="app"></div>  

  <script src="<https://cdn.jsdelivr.net/npm/[email protected]>"></script>
  <script>
    new Vue({
      el: '#app',
      data: {
        title: '鐵人賽第一天 - 組件'
      }
    });
  </script>
</body>
</html>