vant——vant 移动组件库开发注意事项

1、组件文件命名:大驼峰或横线连接。

my-component.vue
MyComponent.vue

2、和父组件紧密耦合的子组件应该以父组件名作为前缀命名。

components/
|- TodoList.vue
|- TodoListItem.vue
└─ TodoListItemButton.vue

3、无内容组件要自闭合

<my-component />

4、Prop名写法

  • 在声明prop时, 使用 驼峰写法
export default {
  props: {
    greetingText: String,
  },
};
  • 在模块中使用时, 使用短横线开隔式写法
<welcome-message greeting-text="hi" />

5、Props 顺序

依次为指令、属性和事件

<my-component
  v-if="if"
  v-show="show"
  v-model="value"
  ref="ref"
  :key="key"
  :text="text"
  @input="onInput"
  @change="onChange"
/>

6、组件选项的顺序

export default {
  name: '',

  components: {},

  props: {},

  emits: [],

  setup() {},

  data() {},

  computed: {},

  watch: {},

  created() {},

  mounted() {},

  unmounted() {},

  methods: {},
};

猜你喜欢

转载自blog.csdn.net/qq_43201350/article/details/121703976
今日推荐