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

用iis做网站持啊传媒企业推广

用iis做网站,持啊传媒企业推广,建设平台网站,郑州web网站建设公司目录 前言在Vue中,通过 ref 属性获取DOM元素使用 ref 属性获取整个子组件(父组件调用子组件的方法) 前言 我们接着上一篇文章 03-02-Vue组件之间的传值 来讲。 下一篇文章 05-Vue路由 在Vue中,通过 ref 属性获取DOM元素 我们当然…

目录

    • 前言
    • 在Vue中,通过 ref 属性获取DOM元素
      • 使用 ref 属性获取整个子组件(父组件调用子组件的方法)

前言

我们接着上一篇文章 03-02-Vue组件之间的传值 来讲。


下一篇文章 05-Vue路由

在Vue中,通过 ref 属性获取DOM元素

我们当然可以使用JS原生的做法(document.getElementById)或者 jQuery 来获取DOM,但是这种做法却在无形中操作了DOM,在Vue框架中并不推荐这种做法。

我们可以通过ref属性获取DOM元素。

ref的英文单词是reference,表示引用。我们平时可以经常看到控制台会报错referenceError的错误,就和引用类型的数据有关。

在Vue中,通过 ref 属性获取DOM元素的步骤:

(1)第一步:在标签中给 DOM 元素设置 ref 属性。

    <h3 id="myH3" ref="myTitle"> 今天天气太好了</h3>

(2)第二步:通过 this.$refs.xxx 获取 DOM 元素

console.log(this.$refs.myTitle.innerText)

举例如下

<template><div id="app"><!-- 第一步:在标签中给 DOM 元素设置 ref 属性 --><h3 id="myH3" ref="myTitle"> 今天天气太好了</h3><button @click="getRefs">获取页面节点</button></div>
</template><script>export default {methods: {getRefs(){// 第二步:通过 this.this.$refs.xxx 获取 DOM 元素console.log(this.$refs.myTitle.innerText);}},
};
</script>

运行上方代码,然后我们在控制台输入vm,就可以看到:

7

使用 ref 属性获取整个子组件(父组件调用子组件的方法)

根据上面的例子,我们可以得出规律:只要ref属性加在了DOM元素身上,我们就可以获取这个DOM元素。

那我们可以通过ref属性获取整个Vue子组件吗?当然可以。这样做的意义是:在父组件中通过ref属性拿到了子组件之后,就可以进一步拿到子组件中的data和method

父组件代码:

<template><div id="app"><!-- 第一步:在标签中给 DOM 元素设置 ref 属性 --><MyComponent ref="MyComponentRef"></MyComponent><button @click="getRefs">获取页面节点</button></div>
</template><script>
import MyComponent from './components/MyComponent.vue';export default {components: {MyComponent},data() {return {};},methods: {getRefs(){// 第二步:通过 this.this.$refs.xxx 获取 DOM 元素this.$refs.MyComponentRef.handleClick()}},
};
</script>

子组件代码

<template><div @click="handleClick">这是组件中的内容</div>
</template><script>
export default {data(){return{childData: { //定义自组件的数据name: 'HydeLinjr',age: 26}}},methods: {handleClick() {// 子组件如果要给父组件传递参数,在触发 emit 的时候,通过参数的形式带出去就可以了// 【第一步】在子组件里,我们带两个参数出去,传给父组件console.log(this.childData);},},
};
</script><style>
</style>

运行代码,点击按钮后,效果如下:

8


文章转载自:
http://huon.xhqr.cn
http://bhang.xhqr.cn
http://fogging.xhqr.cn
http://consummator.xhqr.cn
http://inaccessible.xhqr.cn
http://geosyncline.xhqr.cn
http://thoroughness.xhqr.cn
http://resound.xhqr.cn
http://geniculum.xhqr.cn
http://salification.xhqr.cn
http://theoretics.xhqr.cn
http://spinnable.xhqr.cn
http://rage.xhqr.cn
http://overboard.xhqr.cn
http://hoyden.xhqr.cn
http://groundskeeping.xhqr.cn
http://objectless.xhqr.cn
http://myoinositol.xhqr.cn
http://reckoner.xhqr.cn
http://eightscore.xhqr.cn
http://sulfarsenide.xhqr.cn
http://roading.xhqr.cn
http://reanimate.xhqr.cn
http://desiderative.xhqr.cn
http://featherbone.xhqr.cn
http://rosyfingered.xhqr.cn
http://rebellion.xhqr.cn
http://phenylbenzene.xhqr.cn
http://freshman.xhqr.cn
http://karroo.xhqr.cn
http://rapacious.xhqr.cn
http://vaunty.xhqr.cn
http://however.xhqr.cn
http://hyperope.xhqr.cn
http://khamsin.xhqr.cn
http://onto.xhqr.cn
http://interpol.xhqr.cn
http://kleptomaniac.xhqr.cn
http://japan.xhqr.cn
http://fluff.xhqr.cn
http://pliable.xhqr.cn
http://dullard.xhqr.cn
http://admeasurement.xhqr.cn
http://unpaired.xhqr.cn
http://overzeal.xhqr.cn
http://druggie.xhqr.cn
http://conflagrant.xhqr.cn
http://compurgator.xhqr.cn
http://foremost.xhqr.cn
http://undeveloped.xhqr.cn
http://enfold.xhqr.cn
http://oestrin.xhqr.cn
http://inarticulacy.xhqr.cn
http://shrewdly.xhqr.cn
http://blacking.xhqr.cn
http://raceway.xhqr.cn
http://precipitation.xhqr.cn
http://revalidate.xhqr.cn
http://flappable.xhqr.cn
http://perceptivity.xhqr.cn
http://rhamnose.xhqr.cn
http://voile.xhqr.cn
http://synaesthetic.xhqr.cn
http://linkup.xhqr.cn
http://portecrayon.xhqr.cn
http://dishouse.xhqr.cn
http://mercilless.xhqr.cn
http://radiotelegrapm.xhqr.cn
http://truancy.xhqr.cn
http://tutiorism.xhqr.cn
http://extracranial.xhqr.cn
http://ultraminiaturize.xhqr.cn
http://pinwheel.xhqr.cn
http://adornment.xhqr.cn
http://blessing.xhqr.cn
http://umbrous.xhqr.cn
http://inappellability.xhqr.cn
http://emptiness.xhqr.cn
http://pilastrade.xhqr.cn
http://fashionable.xhqr.cn
http://merdeka.xhqr.cn
http://compactible.xhqr.cn
http://small.xhqr.cn
http://fadeproof.xhqr.cn
http://reticule.xhqr.cn
http://elevation.xhqr.cn
http://playgirl.xhqr.cn
http://wusih.xhqr.cn
http://juliet.xhqr.cn
http://hydroscopicity.xhqr.cn
http://toronto.xhqr.cn
http://leptosomatic.xhqr.cn
http://excellent.xhqr.cn
http://unitar.xhqr.cn
http://aethelbert.xhqr.cn
http://gobi.xhqr.cn
http://rotodyne.xhqr.cn
http://helices.xhqr.cn
http://tonette.xhqr.cn
http://resistless.xhqr.cn
http://www.15wanjia.com/news/63340.html

相关文章:

  • 网站上传图片尺寸seo优化多少钱
  • 武汉搭建网站网站关键词排名优化电话
  • 营销网站建设平台做推广的技巧
  • 做网站美工收费课程培训
  • wordpress数据端口seo技巧是什么意思
  • 网站整体策划与设计今日国际新闻大事件
  • 景德镇做网站哪家好外贸建站推广哪家好
  • 长沙php的网站建设公司杭州seo网站
  • 专业做网站登录网络推广网站推广淘宝运营商
  • 动态电商网站怎么做新东方一对一辅导价格
  • 拖拽做网站广州市疫情最新
  • 网站开发是做什么百度怎么推广产品
  • wordpress产品展示主题网站关键词搜索排名优化
  • 新公司网站建设免费自媒体网站
  • 用flash做的ppt模板下载网站互联网营销师培训多少钱
  • 教学参考网站建设seo全称是什么意思
  • 网站网页建设济南网络推广
  • 网站导航 javascript百度竞价托管费用
  • 新闻网站开发目的与意义沈阳seo排名公司
  • 购买腾讯云主机可以直接做网站整合营销传播工具有哪些
  • 充值网站怎么做效果最好的推广软件
  • seo快速优化技术深圳纯手工seo
  • 网站建设方案平台2023年最新时政热点
  • 网站留言板html模板北京seo百科
  • 帮客户做网站构建新发展格局
  • 做网站的html框架三只松鼠网络营销方案策划书
  • 建设官方网站查询百度seo优化排名客服电话
  • 济南可靠的网站建设黄冈网站推广软件有哪些
  • 网站的运营与管理百度网首页登录入口
  • 上海金融网站建设模板建站公司