我使用Vue 2 Composition API,并希望在我的方法中从 Vue Router 访问路由参数setup()。
如Vue Router 文档中所述:
因为我们无权访问 的
this内部setup,所以我们无法直接访问this.$routerorthis.$route。相反,我们使用该useRouter函数:Run Code Online (Sandbox Code Playgroud)import { useRouter, useRoute } from 'vue-router' export default { setup() { const router = useRouter() const route = useRoute() function pushWithQuery(query) { router.push({ name: 'search', query: { ...route.query, }, }) } }, }
不幸的是,此方法在 Vue 2 的 Vue Router 中不可用。这里有哪些选项以及如何使用 Vue 2 Composition API 访问我的路由参数?
嗨,我是 GraphQL 的新手,我正在尝试根据列内容对我的数据进行排序。我有一个可以发送的查询端点:
query {
user(count:20, firstName:"Foo") {
data {
name
region
birthDate
}
}
}
Run Code Online (Sandbox Code Playgroud)
结果是一个包含 20 个用户名的数组Foo。但我想通过birthDate. 我已经尝试了很多东西,但我就是想不通。我已经尝试过在 firstName之前sort和orderBy之后,但我总是收到错误,例如:
{
"errors": [
{
"message": "Unknown argument \"sort\" on field \"user\" of type \"Query\".",
"extensions": {
"category": "graphql"
},
"locations": [
{
"line": 2,
"column": 31
}
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
我使用 Laravel Lighthouse 作为 GraphQL 的 wapper。我很惊讶我找不到有关如何执行此操作的任何信息。
我的查询:
type Query {
user(firstName: String @eq): [User!]! @paginate(type: "paginator" model: "App\\User")
} …Run Code Online (Sandbox Code Playgroud) 我想获得所有产品流,其中至少有一个类别。我正在尝试这样做:
$criteria = new Criteria();
$criteria->addAssociation('categories');
$criteria->addFilter(new NotFilter(
NotFilter::CONNECTION_OR,
[
new EqualsFilter('categories', null)
// Also tried this:
// new EqualsFilter('categories', ['id' => null])
]
));
$productStreams = $productStreamRepo->search($criteria, $this->context);
Run Code Online (Sandbox Code Playgroud)
但这总是导致以下错误:
Call to a member function buildAccessor() on null
Run Code Online (Sandbox Code Playgroud)
无论我做什么,我总是收到此错误。我做错了什么或者我将如何存档?
我试图要求"ext-SimpleXML": "^7.1"我的composer.json并且我使用 travis 作为我的测试框架。本地一切正常,但在 travis 上(使用时composer install)我总是收到错误消息:
The requested PHP extension ext-simplexml ^7.1 has the wrong version (0.1) installed. Install or enable PHP's simplexml extension.
Run Code Online (Sandbox Code Playgroud)
有谁知道我如何更新或告诉 travis 安装/使用正确的版本?我已经尝试过但sudo apt-get install php-xml没有成功。
php ×3
graphql ×1
laravel ×1
shopware ×1
travis-ci ×1
vue-router ×1
vue-router4 ×1
vue.js ×1
vuejs3 ×1