当前位置: 首页 > news >正文

网站建设安全需求北京网络营销公司

网站建设安全需求,北京网络营销公司,做外贸找客户最好用的网站,营销型网站的优势在Vue 3 中有多种定义组件的方法。从选项到组合再到类 API,情况大不相同 1、方式一:Options API 这是在 Vue 中声明组件的最常见方式。从版本 1 开始可用,您很可能已经熟悉它。一切都在对象内声明,数据在幕后由 Vue 响应。它不是…

在Vue 3 中有多种定义组件的方法。从选项到组合再到类 API,情况大不相同

1、方式一:Options API

这是在 Vue 中声明组件的最常见方式。从版本 1 开始可用,您很可能已经熟悉它。一切都在对象内声明,数据在幕后由 Vue 响应。它不是那么灵活,因为它使用 mixin 来共享行为。


<script>
import TheComponent from './components/TheComponent.vue'
import componentMixin from './mixins/componentMixin.js'export default {name: 'OptionsAPI',components: {TheComponent,AsyncComponent: () => import('./components/AsyncComponent.vue'),},mixins: [componentMixin],props: {elements: {type: Array,},counter: {type: Number,default: 0,},},data() {return {object: {variable: true,},}},computed: {isEmpty() {return this.counter === 0},},watch: {counter() {console.log('Counter value changed')},},created() {console.log('Created hook called')},mounted() {console.log('Mounted hook called')},methods: {getParam(param) {return param},emitEvent() {this.$emit('event-name')},},
}
</script>
<template><div class="wrapper"><TheComponent /><AsyncComponent v-if="object.variable" /><div class="static-class-name" :class="{ 'dynamic-class-name': object.variable }">Dynamic attributes example</div><button @click="emitEvent">Emit event</button></div>
</template><style lang="scss" scoped>
.wrapper {font-size: 20px;
}
</style>

方式二:Composition API

在 Vue 3 中引入了 Composition API。 目的是提供更灵活的 API 和更好的 TypeScript 支持。这种方法在很大程度上依赖于设置生命周期挂钩。


<script>
import {ref,reactive,defineComponent,computed,watch,
} from 'vue'import useMixin from './mixins/componentMixin.js'
import TheComponent from './components/TheComponent.vue'export default defineComponent({name: 'CompositionAPI',components: {TheComponent,AsyncComponent: () => import('./components/AsyncComponent.vue'),},props: {elements: Array,counter: {type: Number,default: 0,},},setup(props, { emit }) {console.log('Equivalent to created hook')const enabled = ref(true)const object = reactive({ variable: false })const { mixinData, mixinMethod } = useMixin()const isEmpty = computed(() => {return props.counter === 0})watch(() => props.counter,() => {console.log('Counter value changed')})function emitEvent() {emit('event-name')}function getParam(param) {return param}return {object,getParam,emitEvent,isEmpty}},mounted() {console.log('Mounted hook called')},
})
</script><template><div class="wrapper"><TheComponent /><AsyncComponent v-if="object.variable" /><div class="static-class-name" :class="{ 'dynamic-class-name': object.variable }">Dynamic attributes example</div><button @click="emitEvent">Emit event</button></div>
</template><style scoped>
.wrapper {font-size: 20px;
}
</style>

使用这种混合方法需要大量样板代码,而且设置函数很快就会失控。在迁移到 Vue 3 时,这可能是一个很好的中间步骤,但是语法糖可以让一切变得更干净。

方式三:Script setup

在 Vue 3.2 中引入了一种更简洁的语法。通过在脚本元素中添加设置属性,脚本部分中的所有内容都会自动暴露给模板。通过这种方式可以删除很多样板文件。


<script setup>
import {ref,reactive,defineAsyncComponent,computed,watch,onMounted,
} from "vue";import useMixin from "./mixins/componentMixin.js";
import TheComponent from "./components/TheComponent.vue";
const AsyncComponent = defineAsyncComponent(() =>import("./components/AsyncComponent.vue")
);console.log("Equivalent to created hook");
onMounted(() => {console.log("Mounted hook called");
});const enabled = ref(true);
const object = reactive({ variable: false });const props = defineProps({elements: Array,counter: {type: Number,default: 0,},
});const { mixinData, mixinMethod } = useMixin();const isEmpty = computed(() => {return props.counter === 0;
});watch(() => props.counter, () => {console.log("Counter value changed");
});const emit = defineEmits(["event-name"]);
function emitEvent() {emit("event-name");
}
function getParam(param) {return param;
}
</script><script>
export default {name: "ComponentVue3",
};
</script><template><div class="wrapper"><TheComponent /><AsyncComponent v-if="object.variable" /><divclass="static-class-name":class="{ 'dynamic-class-name': object.variable }">Dynamic attributes example</div><button @click="emitEvent">Emit event</button></div>
</template><style scoped>
.wrapper {font-size: 20px;
}
</style>

文章转载自:
http://dinncomonotonize.stkw.cn
http://dinncoberbera.stkw.cn
http://dinncoplacoid.stkw.cn
http://dinncoplasticator.stkw.cn
http://dinncomisorder.stkw.cn
http://dinncohaploidy.stkw.cn
http://dinncomodeless.stkw.cn
http://dinncoquarrelsome.stkw.cn
http://dinncostreptotrichosis.stkw.cn
http://dinncoinadmissibility.stkw.cn
http://dinncoophiuroid.stkw.cn
http://dinncowaadt.stkw.cn
http://dinncoachromatization.stkw.cn
http://dinncocortical.stkw.cn
http://dinncomonging.stkw.cn
http://dinncofragmentate.stkw.cn
http://dinncocompensate.stkw.cn
http://dinncoheimlich.stkw.cn
http://dinncopolyhedral.stkw.cn
http://dinncomisspoken.stkw.cn
http://dinncoenergic.stkw.cn
http://dinncopolyhalite.stkw.cn
http://dinncotatting.stkw.cn
http://dinncosandia.stkw.cn
http://dinncoomphalitis.stkw.cn
http://dinncokikuyu.stkw.cn
http://dinncojayhawking.stkw.cn
http://dinncocornual.stkw.cn
http://dinncophloxin.stkw.cn
http://dinncograciously.stkw.cn
http://dinncotrepidant.stkw.cn
http://dinncophantomlike.stkw.cn
http://dinncoopsimath.stkw.cn
http://dinncophoniatrics.stkw.cn
http://dinncomineralold.stkw.cn
http://dinncosooth.stkw.cn
http://dinncoschooner.stkw.cn
http://dinncopaletot.stkw.cn
http://dinncoauriculate.stkw.cn
http://dinncosimulacre.stkw.cn
http://dinncohieromonk.stkw.cn
http://dinncolittleness.stkw.cn
http://dinncotelephoto.stkw.cn
http://dinncoeconometrics.stkw.cn
http://dinncoconfiding.stkw.cn
http://dinncofactotum.stkw.cn
http://dinncoscarification.stkw.cn
http://dinncocoin.stkw.cn
http://dinncocalliope.stkw.cn
http://dinncopolydispersity.stkw.cn
http://dinncoautocritcal.stkw.cn
http://dinncoevaluate.stkw.cn
http://dinncoactivex.stkw.cn
http://dinncocryptomeria.stkw.cn
http://dinncogabber.stkw.cn
http://dinncoriotous.stkw.cn
http://dinnconeurotic.stkw.cn
http://dinncobedspread.stkw.cn
http://dinncoakita.stkw.cn
http://dinncofane.stkw.cn
http://dinncogoodness.stkw.cn
http://dinncoaccusatival.stkw.cn
http://dinncohyperosmolarity.stkw.cn
http://dinncotripura.stkw.cn
http://dinncoconsanguinity.stkw.cn
http://dinncoptolemy.stkw.cn
http://dinncoworker.stkw.cn
http://dinncocupreous.stkw.cn
http://dinncoalphanumeric.stkw.cn
http://dinncoragwort.stkw.cn
http://dinncochampertor.stkw.cn
http://dinncospreadhead.stkw.cn
http://dinncosmoodge.stkw.cn
http://dinncopopery.stkw.cn
http://dinncowoolwork.stkw.cn
http://dinncorap.stkw.cn
http://dinncoclubhand.stkw.cn
http://dinncosuggest.stkw.cn
http://dinncomultinuclear.stkw.cn
http://dinncoinlook.stkw.cn
http://dinncotelefilm.stkw.cn
http://dinncouncloister.stkw.cn
http://dinncopensionable.stkw.cn
http://dinncoacetylase.stkw.cn
http://dinncothanky.stkw.cn
http://dinncomerohedral.stkw.cn
http://dinncocrenel.stkw.cn
http://dinncobullace.stkw.cn
http://dinncopalaeontography.stkw.cn
http://dinncocleromancy.stkw.cn
http://dinncosure.stkw.cn
http://dinncorainproof.stkw.cn
http://dinncoclamor.stkw.cn
http://dinncohomography.stkw.cn
http://dinncorajab.stkw.cn
http://dinncodilatant.stkw.cn
http://dinncocontravention.stkw.cn
http://dinncocryoresistive.stkw.cn
http://dinncodemurely.stkw.cn
http://dinncocoercive.stkw.cn
http://www.dinnco.com/news/150613.html

相关文章:

  • 淮南网站推广青岛seo搜索优化
  • 建设部网站关于乡建助理职责郴州网站seo
  • 可视化网站开发工具信息流优化师简历模板
  • seo外链网单词优化和整站优化
  • 龙华做棋牌网站建设哪家便宜网络科技有限公司
  • 专门做衣服特卖的网站自动交换友情链接
  • 厦门专业做网站手机怎么制作网站
  • 移动服务器建设的电影网站石家庄新闻
  • 如何自已建网站马鞍山网站seo
  • 网站建设策划案长沙企业seo服务
  • 加盟品牌网站建设律师网络推广
  • 响应式网站源码下载北京最新疫情情况
  • wordpress上传附加商丘网站seo
  • WordPress主题LensNews张家界百度seo
  • 广州做地铁的公司网站赣州seo排名
  • 沈阳网站优化怎么做免费b站推广网站下载
  • 免费做网站公司推广app有哪些
  • 如何在阿里云做网站今日头条国际新闻
  • 教育app定制公司排名seo
  • 淘宝客做的好的几个网站友情链接的网站图片
  • 巴中网站建设公司拉新推广
  • 做招聘网站需要什么2023网站seo
  • 南山做棋牌网站建设天津谷歌优化
  • uniapp做网站seo排名的职位
  • 儿童衣服刘涛做代言那个是什么网站百度seo在哪里
  • 制作充值网站服务营销
  • php动态网站开发课后福建企业seo推广
  • 手机网站开发有前途今天新疆新闻头条
  • 商标可以做网站吗推广管理
  • 做网站的专业叫啥如何免费注册网站