javascript - 无法从 [object object] 查询Selector:VueJS
问题描述
我想使用谷歌图表,我想查询选择器里面的一些元素,它返回 null
<template>
<div class="pa-4">
<GChart
ref="gChart"
:settings="{ packages: ['timeline'], state: timeRange }"
type="Timeline"
:data="chartData"
:options="chartOptions"
class="googleChart"
/>
</div>
</template>
在脚本中:
mounted() {
this.nowLine()
},
methods: {
nowLine() {
const gchartQuery = document.querySelector('.googleChart')
console.log(gchartQuery)
console.log(this.$refs.gChart.$el)
},
},
当控制台日志返回时
<div state="[object object]" class="googleChart">...</div>
如果我使用此代码:
const gchartQuery = document.querySelector('.googleChart rect')
console.log(gchartQuery)
它返回 null 我无法查询其中的更多元素。
解决方案
推荐阅读
- c++ - 数组在另一个文件中使用时为空
- python - 如何在 df.loc[df.% Population < 2000] = 0 中转义字符
- sql - SQL~当值相同时如何按字母顺序排序
- r - 整理 - 使用 case_when 重新编码新变量不喜欢我的运算符
- python - 在测试 Django REST Framework 时,为什么我不能让 APIClient.credentials() 使用令牌进行身份验证?
- arrays - 如何将字典的键和值映射到 json 数组?
- c++ - 仅去除带有通配符排除的二进制文件的函数名称
- java - Kafka Java Producer 无法向 kafka 实例发送消息
- javascript - Array.prototype.forEach() json 数组
- hive - Teradata 转换为 hive sql 使用 case when