在vuejs中设置Cookie的最佳做法是什么?我使用SSR,所以我想我不能使用localStorage。
最好的方法是什么?
当我运行jest --coverage
jest 时,只收集 JavaScript 文件的覆盖率,而不是我的 vue 文件。文件夹结构正确。jest.config.js
位于根文件夹中,就像/components
和一样/lib
。对我来说,没有合乎逻辑的解释为什么覆盖率是从 JavaScript 文件中收集的,而不是从 vue 文件中收集的。
这是我的 jest.config.js
module.exports = {
verbose: true,
setupFilesAfterEnv: ['<rootDir>/test-framework-scripts.js'],
moduleFileExtensions: [
'js',
'jsx',
'json',
'vue',
'node',
],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
},
moduleDirectories: [
'node_modules',
'bower_components',
'shared',
'test/tmp',
],
transform: {
'^.+\\.vue$': 'vue-jest',
'.+\\.(css|styl|less|sass|scss|png|jpe?g|ttf|woff|woff2)$': 'jest-transform-stub',
'^.+\\.js$': 'babel-jest',
'^.+\\.svg$': '<rootDir>/jest-svg-transform.js',
'\\.(gql|graphql)$': 'jest-transform-graphql',
},
transformIgnorePatterns: [
'<rootDir>/node_modules/(!gsap)',
],
snapshotSerializers: [
'jest-serializer-vue',
],
testMatch: [
'<rootDir>/test/**/*.spec.(js|jsx|ts|tsx)',
],
testPathIgnorePatterns: [
'<rootDir>/test/client/shared-examples/',
],
testURL: 'http://localhost/',
watchPlugins: …
Run Code Online (Sandbox Code Playgroud) 我想测试一个动态导入另一个组件的组件。
测试正在运行,但我收到警告:
这是我的 .babelrc :
{
"plugins": ["@babel/plugin-syntax-dynamic-import"],
"presets": [
["@babel/env", {
"modules": false
}]
],
"env": {
"test": {
"presets": [
["@babel/env", {
"targets": {
"node": "current"
}
}]
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
还有我的 jest.config.js
module.exports = {
moduleFileExtensions: [
'js',
'json',
// tell Jest to handle *.vue files
'vue',
],
transform: {
// process js with babel-jest
'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
// process *.vue files with vue-jest
'.*\\.(vue)$': '<rootDir>/node_modules/vue-jest',
},
// support the same @ -> src alias mapping in …
Run Code Online (Sandbox Code Playgroud) 我想minmax
为我的grid-template-columns
. 但由于某种原因我无法让它发挥作用。
这是我的代码:
.start {
width: 100%;
display: grid;
grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
grid-template-rows: auto;
grid-gap: 2%;
}
<div class="start">
<div class="news"></div>
<div class="video"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
当我在 Chrome 中检查该类时.start
,它只是显示该minmax
属性的“属性值无效”。
我只想要一个两列布局,当视口变窄时,它会变成一列布局。