【问题标题】:How to use angular.element() in Vue如何在 Vue 中使用 angular.element()
【发布时间】:2019-11-25 03:31:51
【问题描述】:

我以前在 angularjs 中这样使用过。现在我正在迁移到 Vuejs。
如何在 Vuejs 中替换它?

 angular.element(document.querySelector('.popup-inner#company-etc')).css('display', 'none');

【问题讨论】:

  • 在 jQuery 中使用 DOM 在 AngularJS 中是一种不好的做法,所以在 Vue 中也是如此。

标签: angularjs vue.js


【解决方案1】:

你可以使用$refs

<div ref="companyEtc" class="popup-inner" ...

...

this.$refs.companyEtc.style.display = "none"

我建议使用条件渲染:https://vuejs.org/v2/guide/conditional.html

您还可以在问题的答案中找到有关在组件中获取元素的更多信息:VueJs getting an element within a component

【讨论】:

    猜你喜欢
    • 2020-04-30
    • 2012-09-23
    • 2016-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-10
    • 2019-04-19
    • 2020-04-09
    相关资源
    最近更新 更多