简体   繁体   English

Laravel Dusk VueJS SPA 路由器视图注入组件

[英]Laravel Dusk VueJS SPA router-view injected components

I use <router-view> to inject components based on the route.我使用<router-view>根据路由注入组件。 I want to make vue-assertions in Laravel Dusk now.我现在想在 Laravel Dusk 中进行 vue 断言。

<router-view :key="$route.fullPath" :dusk="$route.name"></router-view>

But when I do ->assertVue('field', 'value', '@indexOrder') on my order index route, I get this error:但是当我在我的订单索引路线上执行->assertVue('field', 'value', '@indexOrder')时,我收到此错误:

Facebook\WebDriver\Exception\UnexpectedJavascriptException: javascript error: Cannot read property '__vue__' of null

Of course, I made sure that the route's name is indexOrder and is correctly put in the dusk -attribute of the router-view component.当然,我确保路由的名称是indexOrder并且正确地放在了router-view组件的dusk indexOrder How can I fix that?我该如何解决?

While this is not exactly an answer, it can help move you in the right direction.虽然这不是一个确切的答案,但它可以帮助您朝着正确的方向前进。

When you run the following command in your browser console on the route you're testing, you'll see a $children variable.当您在浏览器控制台中对正在测试的路由上运行以下命令时,您将看到一个$children变量。

document.querySelector('body [dusk="YOUR_ROUTE_NAME"]').__vue__;

The above command is what Dusk executes in its MakesAssertions trait under the vueAttribute method.上面的命令就是在黄昏执行MakesAssertions下特质vueAttribute方法。 This $children variable holds all of your components loaded by the router, so you'll have to create some new methods and assertions to support vue-router in Dusk.这个$children变量保存了路由器加载的所有组件,所以你必须创建一些新的方法和断言来支持 Dusk 中的 vue-router。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM