我在 vue 中定义了一个路由:
/users/:userId
Run Code Online (Sandbox Code Playgroud)
哪个指向 UserComponent:
<template>
<div>{{username}}</div>
</template>
Run Code Online (Sandbox Code Playgroud)
我使用computedfrom@vue/composition-api来获取数据。
问题是当路由更改为另一个时userId,通过导航到另一个用户,html 模板中的用户没有像我预期的那样更改。当用户不在列表中时,它也不会重定向。
那么我能做些什么来解决这个问题?
这是我的代码:
<template>
<div>{{username}}</div>
</template>
<script lang="ts">
import { computed, defineComponent, ref, getCurrentInstance } from '@vue/composition-api';
export const useUsername = ({ user }) => {
return { username: user.name };
};
export default defineComponent({
setup(props, { root }) {
const vm = getCurrentInstance();
const userToLoad = computed(() => root.$route.params.userId);
const listOfUsers = [
{ userId: 1, name: 'user1' },
{ userId: 2, …Run Code Online (Sandbox Code Playgroud) 如何将我的构建目标定位docker-compose 到我所拥有的服务之一docker-compose.yml?
以我docker-compose.yml为例:
version: '3'
services:
admin:
image: 8205037.dkr.ecr.us-east-2.amazonaws.com/admin:latest
build:
context: ../
dockerfile: ./.docker/Dockerfile-admin
www:
image: 233232037.dkr.ecr.us-east-2.amazonaws.com/www:latest
build:
context: ../
dockerfile: ./Dockerfile-www
Run Code Online (Sandbox Code Playgroud)
如何在不更改文件的情况下只构建www?我想运行这样的东西:
docker-compose -f .docker/docker-compose.yml build --target www
如何在我的 vuetify 应用程序中但在 scss 文件中使用媒体查询断点?
例如引导程序使我能够在 scss 文件中执行此操作:
@include media-breakpoint-up(sm) {
.custom-class {
display: block;
}
}
Run Code Online (Sandbox Code Playgroud)
vuetify 中的等价物是什么?我在 vuetify 网站上找不到任何文档
我在我的 TypeScript 组件文件中收到一个错误,指出 prop 不存在,但我完全按照vue-class-component文档示例中的描述声明了 prop 。
Property 'propMessage' does not exist on type 'MyComponent'.Vetur(2339)
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
我正在使用 scss 文件,我想更改 vuetify v2 中 css 端的断点。
我在 vuetify 升级指南中找不到任何参考资料。
在 1.5 版中,我做了 style-x.styl:
$grid-breakpoints := {
xs: 0
sm: 476px
md: 668px
lg: 1000px
xl: 1300px
}
@import '~vuetify/src/styles/styles.sass';
$material-light.background = #f5f5f5;
@import '~vuetify/src/stylus/main';
Run Code Online (Sandbox Code Playgroud)
然后我导入文件:
import '../style-x.styl';
...
Vue.use(Vuetify);
...
Run Code Online (Sandbox Code Playgroud) 在我的 nodejs 应用程序中,我将 graphql 与express-graphql 一起使用。
我看不到库提供的任何缓存选项。我应该如何为 graphql 请求做缓存?(我需要支持get和post)
我已经v-text-field但无法在v-text-fielddom 位置之外显示错误消息。在 vuetify 文档中没有提到这个问题。
是否可以将错误消息放在输入附近?
实际的:
预期的:
<template>
<v-app>
<v-content>
<playground></playground>
<v-text-field
style="width:120px;"
class="numer"
:rules="[rules.required, rules.min, rules.max]"
v-model="numValue"
type="number"
append-outer-icon="add"
@click:append-outer="increment"
prepend-icon="remove"
@click:prepend="decrement"
></v-text-field>
{{numValue}}
</v-content>
</v-app>
</template>
<script>
import Playground from "./components/Playground";
export default {
name: "App",
components: {
Playground
},
data: function() {
return {
numValue: 0,
form: {
min: 2,
max: 10
},
rules: {
required: value => !!value || "Required.",
min: v => v >= this.form.min || `The Min is ${this.form.min}`,
max: …Run Code Online (Sandbox Code Playgroud) 如何在 vue 中删除或添加查询字符串而不更改路由内组件的渲染?
我想在单击按钮时执行此操作:
onClick() {
this.$route.params.add('key', value); //localhost:8080/?key=value
this.$route.params.add('name', value); //localhost:8080/?key=value&name=value
this.$route.params.remove('key') //localhost:8080/?name=value
}
Run Code Online (Sandbox Code Playgroud) 我在我的 Node.js 应用程序中使用 Winston。
const winston = require('winston');
const logger = winston.createLogger({
transports: [
new winston.transports.Console()
]
});
logger.info('What rolls down stairs');
Run Code Online (Sandbox Code Playgroud)
我想添加到日志相关id,但我不想每次都写
logger.info('What rolls down stairs', correlationId);
Run Code Online (Sandbox Code Playgroud)
我希望温斯顿能做到这一点。对于每个日志,我希望获取相关性 ID 作为函数的结果,以便我可以将相关性 ID 发送给用户(而不仅仅是将其输出到控制台)。
const correlationId = logger.info('blabla')
Run Code Online (Sandbox Code Playgroud)
温斯顿可以做到吗?
我创建了一个 lerna monorepo (nodejs 包),并尝试使用 babel 和 webpack 编译我的打字稿文件。
在我的项目中,我有两个主要文件夹:应用程序和包。
我在 packages/package1 中运行构建lerna run build。package1 中的构建脚本是webpack.
在 package1 里面我有一些文件:
webpack.config.js:
const path = require('path');
const root = (p) => path.resolve(__dirname, '../..', p);
const isProd = process.env.NODE_ENV === 'production';
module.exports = {
entry: {
app: './app.ts',
},
output: {
filename: '[name].js',
},
target: 'node',
node: {
__dirname: false,
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
},
},
],
},
resolve: …Run Code Online (Sandbox Code Playgroud) vue.js ×6
vuetify.js ×3
node.js ×2
typescript ×2
vuejs2 ×2
babeljs ×1
css ×1
docker ×1
express ×1
graphql ×1
sass ×1
vue-router ×1
webpack ×1
winston ×1