小编jan*_*doe的帖子

vue-test-utils: 无法覆盖 $route 属性,这通常是由插件将属性添加为只读值引起的

我已经查看了有关此问题的其他答案,似乎是由于尝试导入vue-router测试引起的。然而,这不是我的问题的情况。这是我的测试代码:

import { mount, shallowMount, createLocalVue } from '@vue/test-utils'
import ListDetails from '../components/homepage/ListDetails'
import EntityList from '../components/homepage/EntityList'
import BootstrapVue from 'bootstrap-vue'
import Vuex from 'vuex'
import faker from 'faker'

const localVue = createLocalVue()

localVue.use(Vuex)
localVue.use(BootstrapVue)

describe('ListDetails.vue', () => {
    it('gets the correct page list when router list id param present', () => {
        const selected_list = {
            id: faker.random.number(),
            name: faker.lorem.words(),
            entries: []
        }

        testRouteListIdParam(selected_list)
    })
})
Run Code Online (Sandbox Code Playgroud)

然后在testRouteListIdParam,我有:

function testRouteListIdParam(selected_list) {
    // just assume this sets …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vuejs2 vue-test-utils

9
推荐指数
2
解决办法
6955
查看次数

Vuejs - vuex 计算属性,DOM 未更新

所以我的一个组件中有以下代码:

export default {
    name: 'section-details',
    components: {
        Loading
    },

    mounted() {
        if (!this.lists.length || !this.section_types.length) {
            this.$store.dispatch('section/fetch_section_form_data', () => {
                if (this.section) {
                    this.populate_form();
                }
            });
        }
        else if (this.section) {
            this.populate_form();
        }
    },
    computed: {
        section_types() {
            return this.$store.state.section.section_types;
        },
        lists() {
            return this.$store.state.list.lists;
        },
        loading() {
            console.log(this.$store.state.section.loading);
            this.$store.state.section.loading;
        }
    },
    .
    .
    .
}
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我有一个用于“加载”的计算属性,它在执行 ajax 请求时从我的 vuex 存储中检索属性。

在我的 vuex 模块部分,我有这个:

    fetch_section_form_data({ commit }, callback) {
        commit("isLoading", true);
        sectionService
            .fetch_form_data()
            .then((data) => {
                commit("isLoading", false);
                commit("fetch_section_types_success", …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vuex

2
推荐指数
1
解决办法
1141
查看次数

Google Cloud Pub/Sub 推送消息 - 空 POST

我目前已在Google云平台中成功设置主题和订阅,并已通过Google验证了我的网站并将域添加到GCP。

每当我尝试从https://console.cloud.google.com/cloudpubsub/topics/subscription_sync发送测试消息时,我配置的端点都会收到一些内容,但 POST 变量为空。这是我到目前为止在 php 中的代码,它只是简单地记录 POST 变量(稍后在我的日志中显示为空。)

require_once 'EventPersister.class.php';


$eventPersister = new EventPersister(EventPersister::GOOGLE_WEBHOOKS);

$eventPersister->Persist($_POST);
Run Code Online (Sandbox Code Playgroud)

为了让 POST 数据正确显示,我需要做什么特殊的事情吗?

php google-cloud-platform google-cloud-pubsub

0
推荐指数
1
解决办法
1363
查看次数