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

建设网站需要哪些硬件网络营销组织是什么

建设网站需要哪些硬件,网络营销组织是什么,中国电力建设股份有限公司官方网站,网架公司招聘信息在vue3中定义组件的5种方式 Vue 正在不断发展#xff0c;目前在 Vue3 中定义组件的方法有多种。从选项式到组合式再到类API#xff0c;情况截然不同。本文将会定义一个简单的组件并使用所有可用的方法重构它。 选项式 这是在 Vue 中声明组件的最常见方法。从 Vue1 就开始存…在vue3中定义组件的5种方式 Vue 正在不断发展目前在 Vue3 中定义组件的方法有多种。从选项式到组合式再到类API情况截然不同。本文将会定义一个简单的组件并使用所有可用的方法重构它。 选项式 这是在 Vue 中声明组件的最常见方法。从 Vue1 就开始存在了我们很可能已经熟悉它了。一切都在对象内部声明并且数据在Vue中会定义成响应式。这种方式不是那么灵活因为它使用 mixins 来共享行为。 script import TheComponent from ./components/TheComponent.vue import componentMixin from ./mixins/componentMixin.jsexport 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 templatediv classwrapperTheComponent /AsyncComponent v-ifobject.variable /div classstatic-class-name :class{ dynamic-class-name: object.variable }动态数据/divbutton clickemitEvent触发事件/button/div /templatestyle langscss scoped .wrapper {font-size: 20px; } /style使用这种混合方法需要大量样板代码并且设置的功能会随着项目越来越大越难以维护。 组合式 Vue3 中引入了 Composition API 。目的自然是提供更灵活的 API 和更好的 TypeScript 支持。这种方法在很大程度上依赖于安装生命周期挂钩(hooks)。 script import {ref,reactive,defineComponent,computed,watch, } from vueimport useMixin from ./mixins/componentMixin.js import TheComponent from ./components/TheComponent.vueexport 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)}, }) /scripttemplatediv classwrapperTheComponent /AsyncComponent v-ifobject.variable /div classstatic-class-name :class{ dynamic-class-name: object.variable }动态数据/divbutton clickemitEvent触发事件/button/div /templatestyle scoped .wrapper {font-size: 20px; } /style使用组合式的方式可以项目逻辑更加清晰。 script setup 在 Vue 3.2 中引入了更简洁的语法。通过在 script 标签中添加 setup 属性脚本部分中的所有内容都会自动暴露给模板。通过这种方式同样可以删除很多样板文件。 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; } /scriptscript export default {name: ComponentVue3, }; /scripttemplatediv classwrapperTheComponent /AsyncComponent v-ifobject.variable /div classstatic-class-name :class{ dynamic-class-name: object.variable }动态数据/divbutton clickemitEvent触发事件/button/div /templatestyle scoped .wrapper {font-size: 20px; } /style响应性语法糖 2023 年 1 月 26 日更新这是非常有争议的因此被删除不过我们也可以稍微了解一下 以下使用script setup代码片段中演示的内容存在问题 script setup import { ref, computed } from vueconst counter ref(0) counter.valuefunction increase() {counter.value }const double computed(() {return counter.value * 2 }) /scripttemplatediv classwrapperbutton clickincreaseIncrease/button{{ counter }}{{ double }}/div /template使用.value访问反应式计数器感觉不自然并且是造成混乱和错误输入的常见原因。有一个实验性解决方案利用编译时转换来解决此问题。反应性转换是一个可选的内置步骤它会自动添加此后缀并使代码看起来更干净。 script setup import { computed } from vuelet counter $ref(0) counterfunction increase() {counter }const double computed(() {return counter * 2 }) /scripttemplatediv classwrapperbutton clickincreaseIncrease/button{{ counter }}{{ double }}/div /template$ref.value需要构建步骤但消除了访问变量时的必要性。启用后它在全局范围内可用。 class api Class API 已经存在很长时间了。通常与 Typescript 搭配使用。并且被认真考虑过作为默认的 Vue 3 语法。但经过多次长时间的讨论后它被放弃了取而代之的是 Composition API。它在 Vue 3 中可用但工具明显缺乏官方建议放弃它。 script langts import { Options, Vue } from vue-class-component;import AnotherComponent from ./components/AnotherComponent.vue Options({components: {AnotherComponent} }) export default class Counter extends Vue {counter 0;get double(): number {return this.counter * 2;}increase(): void {this.quantity;} } /scripttemplatediv classwrapperbutton clickincreaseIncrease/button{{ counter }}{{ double }}/div /template
http://www.ihoyoo.com/news/94131.html

相关文章:

  • 南京成旭通网站建设公司怎么样尚海整装公司电话
  • 临城网站济南网站建设cn un
  • 企业网站建设代理公司wordpress 删除标签
  • 公司网站开发公司怎样网站制作设计
  • 启用中文域名大网站天津建设集团网站
  • 昆明网站制作策划自贡跨省特大虚假广告案
  • 青岛市工程建设信息网站网站开发者取色工具
  • 铜川免费做网站公司海外建站公司
  • 虚拟主机可以做视频视频网站吗网站建设350元
  • 文明校园建设专题网站企业宣传ppt案例欣赏
  • 辽宁省营商环境建设局网站谷德设计网案例
  • 蓝色科技企业网站模板免费下载外贸推广代理
  • 学校网站代码做网站设计的电脑需要什么配置
  • 如何建立网站视频教程app拉新推广平台有哪些
  • 海口会计报名网站军事网址大全 网站
  • 12355能找回智慧团建密码吗宁波seo怎么推广
  • 瑞安网站开发没有公司可以注册网站吗
  • flash做企业网站宣传片交互型网站开发
  • 建网站价格 优帮云网站做专题主题该怎么选
  • 全国论坛网站建设郴州网站建设推广公司
  • wordpress还原网站源码房山网站建设服务
  • 宁波做网站的公司iis网站下载
  • 网络网站建设公司wordpress 编写页面代码
  • 网站开发与设计维护的收费标准推进网站 集约化建设
  • 专业营销型网站建设wordpress中一个侧面导航实现异步
  • 公司网站如何更改内容网站程序定制
  • 为企业做网站要向谁索要资料网上注册公司流程及资料
  • 网站持有者和备案企业宿迁莱布拉网站建设
  • 动态链接做网站外链图上海做saas平台网站的公司
  • 昆明网站建设公司哪家便宜二手车网站源码