当前位置: 首页 > 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://www.yidumall.com/news/33274.html

相关文章:

  • 新网 如何建设网站徐州做网站的公司
  • 做视频周边的网站网站优化公司排名
  • 网站建设 银川百度sem认证
  • 建网站的宽带多少钱微营销官网
  • 公安门户网站建设中的问题站长工具查询网
  • 对外贸营销型网站建设的几点建议正规的关键词优化软件
  • 网站开发过程的分工武汉百度seo网站优化
  • 网站的关键词谷歌排名算法
  • 福建做网站seo搜索引擎优化是通过优化答案
  • 长阳网站建设sem账户托管公司
  • 网站开发商官网今天
  • 做购票系统网站丈哥seo博客
  • 用框架做网站如何居中信息推广
  • 无锡网站设计公司排名百度搜索推广流程
  • 搜索引擎作弊的网站有哪些网站发帖推广平台
  • 做面膜的网站廊坊网站
  • 九一人才网赣州找工作aso优化贴吧
  • wordpress网站导入数据库seo策略分析
  • 网站站点层叠样式怎么做一站式媒体发稿平台
  • 汕头网站网店建设成品短视频app下载有哪些
  • 在线做效果图有哪些网站有哪些长春网站制作企业
  • 中企动力做网站费用软文街怎么样
  • 做我的狗在什么网站上看电商运营自学全套教程
  • 电子商务网站界面设计实验报告国家免费技能培训平台
  • 做网站的程序员留备份有哪些平台可以发布推广信息
  • vps网站访问不了佛山网站建设正规公司
  • 怎么用ps做网站上的产品图2021国内最好用免费建站系统
  • 猎奇网站源码google学术搜索
  • 网站建设的大公司东莞百度seo新网站快速排名
  • 海淀重庆网站建设免费网站制作app