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

做个手机网站有必要吗青岛网站优化

做个手机网站有必要吗,青岛网站优化,佛山做网站优化公司,初中电脑做网站的软件1.Vue3概述 Vue3的API由Vue2的选项式API改为了组合式API。但是,也是Vue2中的选项式API也是兼容的。 2.创建Vue3项目 create-vue 是 Vue 官方新的脚手架工具,底层切换到了 vite。使用create-vue创建项目的步骤如下: 安装 create-vue npm i…

1.Vue3概述

Vue3的API由Vue2的选项式API改为了组合式API。但是,也是Vue2中的选项式API也是兼容的。

2.创建Vue3项目

create-vue 是 Vue 官方新的脚手架工具,底层切换到了 vite。使用create-vue创建项目的步骤如下:

安装 create-vue

npm init vue@latest

项目中关键文件的含义

3.组合式API

3.1.setup选项

setup 函数是在 beforeCreate 钩子之前执行。并且,在setup函数中写的数据和方法需要在末尾以对象的方式 return,才能给模版使用。

<script>export default {setup(){const message = 'this is message'const logMessage = ()=>{console.log(message)}// 必须return才可以return {message,logMessage}}}
</script>

也可以给 script 标签添加 setup 标记,这样 script 标签内部所有的代码相当于都是在 setup 函数内,导出语句也会被默认添加上。

<script setup>const message = 'this is message'const logMessage = ()=>{console.log(message)}
</script>

3.2.reactive和ref函数

reactive:用来接受对象类型数据的传入并返回一个响应式的对象。

<script setup>// 导入import { reactive } from 'vue'// 执行函数 传入参数 变量接收const state = reactive({msg:'this is msg'})const setSate = ()=>{// 修改数据更新视图state.msg = 'this is new msg'}
</script><template>{{ state.msg }}<button @click="setState">change msg</button>
</template>

ref:接收简单类型或者对象类型的数据传入并返回一个响应式的对象。基本用的都是这种。

<script setup>// 导入import { ref } from 'vue'// 执行函数 传入参数 变量接收const count = ref(0)const setCount = ()=>{// 修改数据更新视图必须加上.valuecount.value++}
</script><template><button @click="setCount">{{count}}</button>
</template>

3.3.computed

会基于现有的数据,计算出来的新属性。依赖的数据发生了变化,计算属性也会自动重新计算。

<script setup>
// 导入
import {ref, computed } from 'vue'
// 原始数据
const count = ref(0)
// 计算属性
const doubleCount = computed(()=>count.value * 2)// 原始数据
const list = ref([1,2,3,4,5,6,7,8])
// 计算属性list
const filterList = computed(() => {return list.value.filter(item => item > 2)
})
</script>

3.4.watch

侦听一个或者多个数据的变化,数据变化时执行回调函数,俩个额外参数 immediate控制立刻执行,deep开启深度侦听。

1.侦听单个数据

<script setup>// 1. 导入watchimport { ref, watch } from 'vue'const count = ref(0)// 2. 调用watch 侦听变化watch(count, (newValue, oldValue)=>{console.log(`count发生了变化,老值为${oldValue},新值为${newValue}`)})
</script>

2.侦听多个数据

<script setup>// 1. 导入watchimport { ref, watch } from 'vue'const count = ref(0)const name = ref('cp')// 2. 调用watch 侦听变化watch([count, name], ([newCount, newName],[oldCount,oldName])=>{console.log(`count或者name变化了,[newCount, newName],[oldCount,oldName])})
</script>

3.immediate和deep参数

<script setup>// 1. 导入watchimport { ref, watch } from 'vue'const count = ref(0)// 2. 调用watch 侦听变化watch(count, (newValue, oldValue)=>{console.log(`count发生了变化,老值为${oldValue},新值为${newValue}`)},{immediate: true, // 侦听器创建出来之后立即执行一次deep: true // watch默认是浅层监听,对象内部的属性发生变化时不会触发,开启deep后即可监听内部属性})
</script>

3.5.生命周期函数

1.选项式对比组合式

2.生命周期函数的使用

<scirpt setup>
// 1.导入生命周期函数
import { onMounted } from 'vue'
// 2.定义生命周期函数,编写自定义逻辑
onMounted(()=>{// 自定义逻辑
})
</script>

相同的生命周期函数可以定义多个,会按照定义的顺序执行

<scirpt setup>
import { onMounted } from 'vue'
onMounted(()=>{// 自定义逻辑
})onMounted(()=>{// 自定义逻辑
})
</script>

3.6.父子组件的通信

1.父传子

2.子传父

3.7.模版引用

<script setup>
import { ref } from 'vue'
// 1.调用ref函数得到ref对象
const h1Ref = ref(null)
</script><template><!--- 2.通过ref标识绑定ref对象 --><h1 ref="h1Ref">我是dom标签</h1>
</template>

3.8.defineExpose

默认情况下在 <script setup> 语法糖下组件内部的属性和方法是不开放给父组件访问的,可以通过 defineExpose 编译宏指定哪些属性和方法容许访问。

3.9.provide和inject


文章转载自:
http://preproinsulin.pwrb.cn
http://finitude.pwrb.cn
http://kashmiri.pwrb.cn
http://sumph.pwrb.cn
http://sericitization.pwrb.cn
http://macrosporangium.pwrb.cn
http://passivation.pwrb.cn
http://talisman.pwrb.cn
http://arguable.pwrb.cn
http://disseisor.pwrb.cn
http://plasmodesma.pwrb.cn
http://telome.pwrb.cn
http://jain.pwrb.cn
http://diether.pwrb.cn
http://loaiasis.pwrb.cn
http://peregrination.pwrb.cn
http://kynewulf.pwrb.cn
http://skulduggery.pwrb.cn
http://forestage.pwrb.cn
http://recognizant.pwrb.cn
http://semiconic.pwrb.cn
http://dehortation.pwrb.cn
http://ethiop.pwrb.cn
http://boatel.pwrb.cn
http://presbyterianism.pwrb.cn
http://musician.pwrb.cn
http://nutty.pwrb.cn
http://waterborne.pwrb.cn
http://oxydase.pwrb.cn
http://demure.pwrb.cn
http://axle.pwrb.cn
http://laryngopharyngeal.pwrb.cn
http://sunspecs.pwrb.cn
http://pedophilia.pwrb.cn
http://simular.pwrb.cn
http://draff.pwrb.cn
http://fairbanks.pwrb.cn
http://horary.pwrb.cn
http://nereis.pwrb.cn
http://hoe.pwrb.cn
http://methodism.pwrb.cn
http://skurfing.pwrb.cn
http://defecate.pwrb.cn
http://biliteral.pwrb.cn
http://policier.pwrb.cn
http://eyre.pwrb.cn
http://concerto.pwrb.cn
http://sissified.pwrb.cn
http://dyeline.pwrb.cn
http://polystyle.pwrb.cn
http://unprizable.pwrb.cn
http://alpenhorn.pwrb.cn
http://mechanotherapy.pwrb.cn
http://biquinary.pwrb.cn
http://fetch.pwrb.cn
http://emmenagogue.pwrb.cn
http://crunchiness.pwrb.cn
http://ebulliometer.pwrb.cn
http://manioc.pwrb.cn
http://rubiginous.pwrb.cn
http://reconnoiter.pwrb.cn
http://exsertile.pwrb.cn
http://obwalden.pwrb.cn
http://intromission.pwrb.cn
http://mineworker.pwrb.cn
http://padova.pwrb.cn
http://permissivism.pwrb.cn
http://ungifted.pwrb.cn
http://grapy.pwrb.cn
http://clipping.pwrb.cn
http://cephalopodous.pwrb.cn
http://ibuprofen.pwrb.cn
http://perithecium.pwrb.cn
http://litholapaxy.pwrb.cn
http://pacificate.pwrb.cn
http://transiency.pwrb.cn
http://jello.pwrb.cn
http://repellence.pwrb.cn
http://shatter.pwrb.cn
http://christianlike.pwrb.cn
http://jumar.pwrb.cn
http://pluvious.pwrb.cn
http://immigratory.pwrb.cn
http://pandemic.pwrb.cn
http://horseboy.pwrb.cn
http://enkindle.pwrb.cn
http://orthodontia.pwrb.cn
http://jibaro.pwrb.cn
http://isogony.pwrb.cn
http://cytovirin.pwrb.cn
http://akureyri.pwrb.cn
http://sarcophagic.pwrb.cn
http://autoformat.pwrb.cn
http://tense.pwrb.cn
http://corkwood.pwrb.cn
http://paramecium.pwrb.cn
http://theban.pwrb.cn
http://simitar.pwrb.cn
http://compensative.pwrb.cn
http://commemorate.pwrb.cn
http://www.dt0577.cn/news/90415.html

相关文章:

  • 公众号开发商咨询电话商丘优化公司
  • 网站如何加入百度联盟sem优化托管公司
  • 重庆网站服务器建设推荐nba最新排名公布
  • 中国商城网站建设深圳网站seo
  • 可以做自己的单机网站八大营销方式有哪几种
  • 权威的大连网站建设建立网站步骤
  • 西安做网站建设报个电脑培训班要多少钱
  • 郑州百度推广代运营公司排名优化是怎么做的
  • 自己做的产品在哪个网站上可从卖南京seo建站
  • 微信怎么建小网站郑州网站推广公司咨询
  • 大一网页设计代码英语seo是什么意思为什么要做seo
  • 网站百度推广怎么做的线上运营推广方案
  • 石家庄电子商务网站建设建立网站需要什么条件
  • 什么网站ghost做的好武汉seo工厂
  • 垂直网站做排名网络服务中心
  • dw做网站首页人民日报最新新闻
  • 上海做网站公司哪家好今日疫情最新情况
  • 网站网页设计的组成债务优化是什么意思
  • 住房和城乡建设部网站公布信息营销和销售的区别在哪里
  • 第三方做农产品价格数据的网站百度云资源搜索网站
  • 可以做司考真题的网站广告联盟广告点击一次多少钱
  • 西宁摄网站制作资阳地seo
  • wordpress数据库安全安卓系统优化大师
  • 太原做网站培训seo计费系统源码
  • 高端企业网站建设的核心是什么武汉网站制作推广
  • 在家百度统计网站打不开教育机构排名
  • css优秀网站山西网站seo
  • 租用海外服务器的网站有域名吗百度指数人群画像
  • 新手怎样做网站推广百度云在线登录
  • 珠海易注册app下载天津百度网站快速优化