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

包装设计网站欣赏地推公司排名

包装设计网站欣赏,地推公司排名,做网站什么意思,开发公司项目总职责一. 关于局部组件组成的三个部分&#xff08;template, script, style&#xff09; template > 组件的模板结构 &#xff08;必选&#xff09; 每个组件对应的模板结构&#xff0c;需要定义到template节点中 <template><!-- 当前组件的dom结构&#xff0c;需…

一. 关于局部组件组成的三个部分(template, script, style)

  1. template  =>  组件的模板结构  (必选)

  • 每个组件对应的模板结构,需要定义到template节点中
<template><!-- 当前组件的dom结构,需要定义到template结构的内部 -->
</template>
  • template中使用的指令
<template><!-- 【1.内容渲染指令】 --><span v-text="msg"></span><span>{{msg}}</span><div v-html="html"></div><!-- 【2.属性绑定指令】 --><img v-bind:src="imageSrc"><!-- 【3.双向指令绑定指令】 --><select v-model=""></select><!-- 【4.循环渲染指令】 --><div v-for="(item, index) in items"></div><!-- 【5.条件渲染】 --><div v-if="Math.random() > 0.5">Now you see me</div><div v-else-if="type === 'B'"></div><div v-else>Now you don't</div>
</template>
  • template定义根节点

注:vue 2.x版本中,<template>节点内dom结构仅支持单个根节点;但在vue 3.x版本中,支持多个根节点

  1. script  =>  组件的javascript行为  (可选)

  • script中的data节点(可以定义当前组件渲染期间需要用到的数据对象;data是一个函数)
  • script中的methods节点(可以定义组件中的事件处理函数)
  1. style  =>  组件的样式  (可选)

  • style的lang属性支持可选值css,less,sass,scss
  • 当使用less或sass时,要先安装less或sass依赖,再设置lang的属性值为less或sass
  • scss是sass3.0引入的语法,可以理解scss是sass的一个升级版本,弥补sass和css之间的鸿沟
  • 合理使用scoped,因为使用scoped可以让样式只对当前组件生效

二. 关于生命周期

  • beforeCreate
  • created
  • beforeMounted
  • mounted
  • beforeUpdate
  • updated
  • beforeDestory
  • destoryed

created和mounted的区别:created在模板渲染成html前调用,mounted在模板渲染成html后调用

三. 关于父子组件的传值

封装出来的通用组件叫子组件,引用通用组件的界面叫做父组件,组件的封装必须高性能低耦合

1. 父组件向子组件传参用props

<!-- 父组件 -->
<template><Child :articleList="articleList"></Child>
</template><!-- 子组件 -->
<template><div><ul><li v-for="(value,index) in articleList" :key="index">{{value}}</li></ul></div>
</template><script>export default {name: "Child",props: {articleList: {type: array,default: function () {return []}    }},//接收父组件传来的数据articleList}
</script>

2. 子组件向父组件传参用emit

<!-- 父组件 -->
<template><common-dialog @pushId="getId"></common-dialog>
</template>
<script>methods: {getId (id) {}}
</script><!-- 子组件 -->
<template><div><input type="button" @click="emitIndex(id)" value="向父组件发送数据"></div>
</template>
<script>export default {methods: {emitIndex (id) {this.$emit('pushId', id)}}}
</script>

四. 关于computed与watch

1. computed与watch的区别:

  • computed是计算属性,watch是监听,监听data中的数据变化
  • computed支持缓存,即当其依赖的属性值发生变化时,计算属性会重新计算,反之则使用缓存中的属性值;watch不支持缓存,当对应属性发生变化的时候,响应执行
  • computed不支持异步,有异步操作时无法监听数据变化;watch支持异步

2. computed与watch的使用场景

  • computed的使用
<template><div>{{ changewords }}</div>
</template>
<script>export default {data () {myname: 'aBcDEf'},computed: {changewords(){return this.myname.substring(0,1).toUpperCase()}}   }
</script>
  • watch的使用
<template><div><p>FullName: {{fullName}}</p><p>FirstName: <input type="text" v-model="firstName"></p></div>
</template>
<script>export default{data () {firstName: 'Dawei',lastName: 'Lou',fullName: ''},watch: {firstName(newName, oldName) {this.fullName = newName + ' ' + this.lastName;}// firstName: {//     handler(newName, oldName) {//        this.fullName = newName + ' ' + this.lastName;//     },//     immediate: true// }}}
</script>

五. 关于mixin

局部混入中mixin的文件就是一个对象,这个对象可以包含vue组件的一些常见的配置,包括data,methods,生命周期的钩子函数等等。

不同组件中的mixin是相互独立的。

  • mixin的使用

<!-- 引用mixins的文件 -->
<script>import queryList from "@/common/mixin/queryList";export default{mixins: [queryList]}
</script><!-- mixins的文件 -->
export const mixins = {data() {return {};},computed: {},created() {},mounted() {},methods: {},
};

六. 关于slot的使用

<!-- 子组件使用插槽slot   Link.vue-->
<template><a :href="href" rel="external nofollow"  class="link"><!-- 留个插槽,外界传入内容放置在这里 --><slot></slot></a>
</template><!-- 父组件调用子组件 -->
<template><div class="app"><Link href="https://baidu.com" rel="external nofollow" > 百度</Link><Link href="https://google.com" rel="external nofollow"  style="margin-top: 10px"><!-- 这里允许放置任意的内容,包括字符串和标签 --><span>Icon</span>谷歌</Link</Link></div>
</template>

七. 关于vuex

vuex的五个组成部分:state,mulations,action,getters,modules

  • state:定义了应用程序的状态,即要管理的数据
const store = new Vuex.Store({state: {count: 0}
})
  • getters:用于获取state中的状态,类似vue组件中的计算属性
const store = new Vuex.Store({state: {count: 0},getters: {doubleCount(state) {return state.count * 2}}
})
  • mulations:修改state的数据
const store = new Vuex.Store({state: {count: 0},mutations: {increment(state) {state.count++},add(state, payload) {state.count += payload}}
})
  • action:用于异步操作和提交mulations,在actions中可以进行任何异步操作,最后再提交到mulations中同步修改state
const store = new Vuex.Store({state: {count: 0},mutations: {increment(state) {state.count++}},actions: {incrementAsync(context) {setTimeout(() => {context.commit('increment')}, 1000)}}
})
  • modules:用于将store分割成模块,每个模块都拥有自己的state, getters, mulations, action和子模块,以便提高应用程序的可维护性
const store = new Vuex.Store({modules: {cart: {state: {items: []},mutations: {addItem(state, item) {state.items.push(item)}},actions: {addAsyncItem(context, item) {setTimeout(() => {context.commit('addItem', item)}, 1000)}}}}
})

http://www.hkea.cn/news/404530/

相关文章:

  • 南乐县住房和城乡建设局网站制作网站的步骤是什么
  • 金华做网站最专业的公司搜易网提供的技术服务
  • wordpress适合门户网站吗怎么营销自己的产品
  • 常用的网站类型有哪些seo优化专员编辑
  • 网站专题框架怎么做海阳seo排名
  • 手机网站代码下载黄页网站推广服务
  • 做网站前端多少钱在线bt种子
  • wordpress+模版+推荐专业网站seo推广
  • 浦项建设公司员工网站2023免费推广入口
  • 如何查询某个网站的设计公司最新推广注册app拿佣金
  • 八宝山做网站公司打广告
  • wordpress vip查看插件南宁seo费用服务
  • 建站之星模板怎么设置手机如何做网站
  • 上海公司网站制作价格西安百度关键词排名服务
  • 长沙网页制作开发公司aso优化方案
  • 深圳罗湖网站制作成人电脑基础培训班
  • 无锡网站制作咨询深圳网站设计十年乐云seo
  • 大连城市建设网站seo优化顾问服务阿亮
  • 福州 网站建设沈阳seo关键词排名优化软件
  • 做网站还要买服务器吗镇江seo
  • 专门做特价的网站优化排名案例
  • 网站建设的一些问题友链交易交易平台
  • 创业初期要建立公司的网站吗seo排名优化代理
  • 做网站全屏尺寸是多少钱站长工具查询系统
  • 做企业平台的网站有哪些手机网站制作教程
  • 免费行情的软件大全下载北京公司排名seo
  • 网站联系方式要素qq群推广链接
  • div css 网站模板免费的云服务器有哪些
  • 35互联做网站好吗网店运营工作内容
  • 网站建设模拟软件营销培训课程内容