Browse Source

Signed-off-by: Caner <40012261+Canees@users.noreply.github.com>

Caner 3 years ago
parent
commit
119dda9e9f
1 changed files with 50 additions and 0 deletions
  1. 50 0
      README.md

+ 50 - 0
README.md

@@ -5,6 +5,54 @@
 
 ```
 
+# 建议使用setup方式(Composition API),请注意书写格式!
+```
+import { onMounted, ref, computed} from 'vue'
+<script setup>
+    <!-- data 数据声明区 -->
+      exp:
+        const test=ref(1)
+        const test1:computed(()=>test)
+
+    <!-- function 调用区 -->
+      exp:
+       const test= ()=>{
+          console.log(123)
+        }
+
+    <!-- 单独生命周期监听区 -->
+      exp:
+        onMounted(() => {test()})
+</script>
+
+```
+
+# 鼓励使用option api 方式
+```
+export default {
+    props:{name:String},
+
+    <!-- 注意setup 和 data 使用其一即可 -->
+    setup(){
+      const test= ref(1)
+      return { test }
+    },
+
+    <!-- 注意setup 和 data 使用其一即可 -->
+    data() {
+        return {
+          greeting: 'Hello World!'
+        }
+    },
+
+    mounted(){
+      console.log(123)
+    }
+}
+</script>
+
+```
+
 ## use
 ```
 yarn
@@ -121,4 +169,6 @@ import { useCounterStore } from '../model/counter'
    7. view-ui-plus   
 6. eslintignore 增加排除文件
 7. echarts 使用import * as echarts from 'echarts'
+8. 组件嵌套层级超过3层建议使用 provide/inject 方式
+
 ```