我有一个导航项目列表,在加载时单击列表中的第一个元素<li class="nav-item" v-for="(checkoutplan, index) in checkoutplans" :key="checkoutplan.id"> <a class="nav-link" :class="{ 'active show' : index === 0 }" href="#settings" data-toggle="tab" @click="editModal(checkoutplan)">Checkout Plan {{index +1}}</a></li>我在想什么 document.querySelector("li[class='nav-item']").click()也不document.querySelector("li.nav-item:first-child").click()没用 created() { axios.get("api/checkoutplan") .then(({ data }) => {this.checkoutplans = data;document.querySelector("a.nav-link:first-child").click();}); }
3 回答
繁花不似锦
TA贡献1851条经验 获得超4个赞
var button = document.querySelector("input[type=button]");
button.addEventListener("click", function() {
alert("button was clicked");
})
添加回答
举报
0/150
提交
取消