我按照这篇中等文章作为在 firebase 托管上托管我的 nuxt 应用程序的指南。
但是,部署会通过,然后当我访问该url 时,我收到一条Cannot GET /错误消息。如果我检查函数日志,我会看到函数完成时出现 404 错误。
这是我的函数/index.js
const functions = require('firebase-functions')
const admin = require("firebase-admin")
const { Nuxt } = require('nuxt-start')
const nuxtConfig = require('./nuxt.config.js')
admin.initializeApp()
const config = {
...nuxtConfig,
dev: false,
debug: true,
buildDir: "nuxt",
publicPath: "public",
}
const nuxt = new Nuxt(config)
exports.ssrapp = functions.https.onRequest(async (req, res) => {
await nuxt.ready()
nuxt.render(req, res)
})
Run Code Online (Sandbox Code Playgroud)
这是firebase配置
{
"functions": {
"source": "functions",
"predeploy": [
"npm --prefix src …Run Code Online (Sandbox Code Playgroud) 我有一个带有由fast_jsonapi gem序列化的模型的Rails api。
我的模型如下所示:
class Shift < ApplicationRecord
belongs_to :team, optional: true
...
Run Code Online (Sandbox Code Playgroud)
class Team < ApplicationRecord
has_many :shifts
...
Run Code Online (Sandbox Code Playgroud)
这就是序列化器的样子
class ShiftSerializer
include FastJsonapi::ObjectSerializer
...
belongs_to :team
...
end
Run Code Online (Sandbox Code Playgroud)
序列化工作。但是,即使我包含复合团队文档:
def index
shifts = policy_scope(Shift).includes(:team)
options = {}
options[:include] = [:team, :'team.name', :'team.color']
render json: ShiftSerializer.new(shifts, options)
end
Run Code Online (Sandbox Code Playgroud)
我仍在像这样格式化对象:
...
relationships: {
team: {
data: {
id: "22",
type: "Team"
}
}
}
Run Code Online (Sandbox Code Playgroud)
而我期望也能获得团队模型的属性。
我第一次使用 vue-test-utils 在 Vue 应用程序中实现一堆单元测试。测试确实有效,但是,我想干燥代码。
目前我正在将以下代码添加到每个测试中:
const wrapper = shallowMount(ConceptForm, {
localVue,
router,
propsData: { conceptProp: editingConcept }
});
Run Code Online (Sandbox Code Playgroud)
使测试看起来像这样
it('shows the ctas if the state is equal to editing', () => {
const wrapper = shallowMount(ConceptForm, {
localVue,
router,
propsData: { conceptProp: editingConcept }
});
expect(wrapper.find('#ctas').exists()).toBe(true)
});
Run Code Online (Sandbox Code Playgroud)
我这样做是因为我需要将这个特定的 propsData 传递给包装器。有什么方法可以让我在 beforeEach 中浅层安装组件,然后传递 prop 吗?
谢谢!