小编Van*_*anz的帖子

如何将 mapActions 与 vue + Typescript 类组件一起使用?

我想知道...mapActions([])在 Typescript vue 类组件中使用的正确方法是什么。

这就是我的做法:

<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { mapActions } from "vuex";

@Component
export default class UsersAdd extends Vue {
  userName: string = "";

    ...mapActions(["newUser"]) /*mapAction from vuex */
  addUser() {
    console.log("...adding new user");
    this.newUser(this.userName);
  }
}
</script>
Run Code Online (Sandbox Code Playgroud)

正如你所知道的,它不起作用......

使用Javascript我这样做。

methods:{
  ...mapActions(["newUser"])
}
Run Code Online (Sandbox Code Playgroud)

我如何使用 Typescript 类组件来做到这一点?

编辑: 我已经尝试过这种方式,但它仍然无法正常工作

@Component({
  methods: {
    ...mapActions(["newUser"]) /*mapAction from vuex */
  }
})
export default class UsersAdd extends Vue {
  userName: string …
Run Code Online (Sandbox Code Playgroud)

typescript vue.js vue-component vuex vuejs2

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

vuejs vue-cli 如何使用console.log 而不会出现任何错误

我想看看结果变量的内容是什么。

const result = await axios.post('/login', {
    email: user.email,
    password: user.password
});
console.log(result);
Run Code Online (Sandbox Code Playgroud)

在我运行“npm run serve”之后

我收到一个错误,无法编译使用控制台。

在此处输入图片说明

使用 vue-cli 时有没有办法使用控制台?

vue.js vue-cli-3

8
推荐指数
1
解决办法
5885
查看次数

Vue js Vue-cli 执行“npm run build”,将图像不透明度的 css 编译为 1%

当我npm run serve按预期执行所有工作时。

当我执行时npm run build,“没有错误”。

当我在网站上掠夺图像时无法看到图像,然后我检查元素我看到我的画廊部分中的图像不透明度更改为 1%。

在此处输入图片说明

这是我的模板代码:

<div class="gallery container">
  <div
    class="images"
    v-for="(image, index) in images"
    :key="index"
  >
    <img :src="image.small" @click="selectImage(index)" />
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我的 scss 代码:

 <style lang="scss" scoped>
    .gallery-wrapper {
      padding: 3rem 0;
      .gallery {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        align-items: center;
        .images {
          display: flex;
          justify-content: center;
          align-items: center;
          img {
            height: auto;
            cursor: pointer;
            width: 100%;
            opacity: 85%;
            border: 5px solid aliceblue;
            &:hover {
              opacity: 100%;
              transition: 0.5s;
              border: none; …
Run Code Online (Sandbox Code Playgroud)

npm vue.js

8
推荐指数
1
解决办法
786
查看次数

Laravel 有两个来自同一张表的外键

嗨,我不太擅长数据库设计,所以我想知道是否可以从同一个表中创建一个带有两个外键的表。

这是我试图展示这种关系的努力 在此处输入图片说明

我是否可以使用 Laravel 迁移来做到这一点我已经尝试过但它不起作用

Schema::create('events', function (Blueprint $table) {
        $table->increments('event_id');
        $table->integer('book_id')->unsigned();
        $table->integer('buyers_id')->unsigned();
        $table->integer('seller_id')->unsigned();
        $table->integer('status')->default(1);
        $table->timestamps();

        $table->foreign('book_id')->references('id')
        ->on('books')
        ->onDelete('cascade')
        ->onUpdate('cascade');
        $table->foreign('buyers_id')->references('id')
        ->on('users')
        ->onDelete('cascade')
        ->onUpdate('cascade');
        $table->foreign('seller_id')->references('id')
        ->on('users')
        ->onDelete('cascade')
        ->onUpdate('cascade');
    });
Run Code Online (Sandbox Code Playgroud)

所以事件表将有 3 FK

  • 书中的一个 FK
  • 来自用户的两个 FK

     Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
    
        $table->string('name')->unsigned();
    
        $table->integer('user_type');
    
        $table->integer('password');
    
        $table->timestamps();
    
    
    });
    
    Run Code Online (Sandbox Code Playgroud)

这是用户表的架构

database-design database-migration laravel

7
推荐指数
1
解决办法
5616
查看次数

PYTHON 3.7 _tkinter.TclError:无效的命令名称“tixBalloon”

您好,我正在尝试创建一个按钮,该按钮在悬停时会显示说明。类似于 html img 标签“alt”,我决定将“tkinter.pix”与 Balloon() 一起使用,但出现错误:_tkinter.TclError:无效的命令名称“tixBalloon”。

from tkinter import *
from tkinter import tix


class MyClass:

    def __init__(self, master):
        self.master = master
        self.btn_1 = Button(self.master, text="Button")
        self.btn_1.pack()

        self.bal = tix.Balloon(self.master)

        self.bal.bind_widget(self.btn_1, balloonmsg="Hello")
root = Tk()
app= MyClass(root)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)

python tkinter tix python-3.x

5
推荐指数
1
解决办法
1411
查看次数

Vue - 反应式内的组合 API 数组未在 DOM 中更新

我在reactive()中有一个帖子数组,我希望它在Mounted上更新。

我怎样才能做到这一点?

模板:

<q-card>
  <board-item-list :items="items" v-if="items.length" />
  <board-empty v-else />
</q-card>
Run Code Online (Sandbox Code Playgroud)

脚本

import { reactive, onMounted } from "vue";
import { posts } from "./fake-data.js";
export default {
  setup() {
    let items = reactive([]);
    ...
    onMounted(() => {
      // to fill the items with posts.
      items.values = posts; // I tried this not working
      items = posts; //I tried this not working
      console.log(items);
    });
    ...
    return {
      ...
      items,
    };
  },
};
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vuejs3 vue-composition-api

4
推荐指数
1
解决办法
6376
查看次数

Python 3 tkinter消息框突出显示"否"按钮?

我想创建一个确认删除意图的消息框.

    def delete_action(self):
    s_id = self.selected_ID_entry.get()
    s_name = self.seletedEntry.get()
    answer = messagebox.askquestion("Delete?","Are you sure you want to delete {}".format(s_name), icon='warning')

    if answer == 'yes':
        #deleted function here
    else:
        #not deleted function here
Run Code Online (Sandbox Code Playgroud)

如何突出显示"否"按钮而不是"是"按钮?

这样的事情

python tkinter messagebox python-3.x

3
推荐指数
1
解决办法
421
查看次数

Quasar q-icon 使用资产文件夹中的图标

我的资产文件夹中有一个名为“home.svg”的图标。如何指示我的q-icon组件获取目录内的图标assets/

我尝试过这样应用:

  <q-icon name="img:/assets/home.svg" class="text-dark" style="font-size: 32px;" />
Run Code Online (Sandbox Code Playgroud)

但图像没有被渲染。

在此输入图像描述

vue.js quasar quasar-framework

3
推荐指数
1
解决办法
7238
查看次数

Fastify - 如何使用 fastify-multipart 获取非文件字段

如何从请求中访问非文件字段的文本?(我正在使用Insomia

我们使用 Insomia 的请求 在此输入图像描述

我们可以通过循环各部分来访问文件字段。使用const parts = await req.files();

索引.js

    import Fastify from "fastify";
    import FastifyMultipart from "fastify-multipart";
    
    export const fastify = await Fastify();
    fastify.register(FastifyMultipart);
Run Code Online (Sandbox Code Playgroud)

控制器/property.js

    export const addProperty = async function (req, res) {
      try {
        // WE ACCESS FILES OF MULTIPART FORM REQUEST HERE
        const parts = await req.files();
        for await (const data of parts) {
          console.log("*******File being access**********");
          console.log(data.filename); // access file name
          ...
        }
        // HOW DO WE …
Run Code Online (Sandbox Code Playgroud)

javascript node.js fastify fastify-multipart

3
推荐指数
1
解决办法
4261
查看次数

单击另一个按钮时,Quasar 切换 q 文件

在 Quasar 框架中,当我单击某个按钮时如何切换文件选择器q-file

到目前为止我的努力:

当单击此按钮时,它应该切换q-file

<button @click="toggleFileSelector">toggle file selector</button>
Run Code Online (Sandbox Code Playgroud)

所以我有这个文件选择器,我希望在单击按钮时切换它

<q-file outlined class="field" ref="myFileSelector" :label="label" v-model="myFile">
  <template v-slot:append>
    <div class="attachment notosanskr-medium">File</div>
  </template>
</q-file>
Run Code Online (Sandbox Code Playgroud)

切换方法:

  methods: {
    toggleFileSelector() {
      this.$refs.myFileSelector.toggle();
    },
  },
Run Code Online (Sandbox Code Playgroud)

但我收到错误:

“类型错误:this.$refs.myFileSelector.toggle 不是函数”

javascript vue.js vue-component vuejs2 quasar-framework

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