前端——Vue3笔记之注意事项

1.获取对应节点

组件中使用jquery,嵌套比较深的情况下$('.className')获取不到对应的节点时,可以使用ref属性获取到对应节点。

<div class="panel" ref="panel">

方式一:借助jquery

import $ from 'jquery'

const panel = ref(null)

$(paneltips.value).hide();  //隐藏

方式二:

const panel = ref(null)

panel.value.style.display="none"  //隐藏

2.动态渲染的html结构,其样式不能是scoped

3.样式deep穿刺

一般使用 scoped 后,父组件的样式将不会渗透到子组件中,这个时候就要用到 /deep/
尤其是当我使用 scoped 后,又引用了 element 这类组件,想要改变element组件的部分样式时,
直接使用class命名改变样式没有任何反应,这里就要在样式前加上 /deep/ 或者 

 /deep/ .el-pager {
      padding-left: 0 !important;
    }

猜你喜欢

转载自blog.csdn.net/helloyangkl/article/details/127916910