我想知道...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) 我想看看结果变量的内容是什么。
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 时有没有办法使用控制台?
当我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) 嗨,我不太擅长数据库设计,所以我想知道是否可以从同一个表中创建一个带有两个外键的表。
我是否可以使用 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
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)这是用户表的架构
您好,我正在尝试创建一个按钮,该按钮在悬停时会显示说明。类似于 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) 我在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) 我想创建一个确认删除意图的消息框.
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)
如何突出显示"否"按钮而不是"是"按钮?
我的资产文件夹中有一个名为“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)
但图像没有被渲染。
如何从请求中访问非文件字段的文本?(我正在使用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) 在 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 不是函数”
vue.js ×6
javascript ×3
python ×2
python-3.x ×2
tkinter ×2
vuejs2 ×2
fastify ×1
laravel ×1
messagebox ×1
node.js ×1
npm ×1
quasar ×1
tix ×1
typescript ×1
vue-cli-3 ×1
vuejs3 ×1
vuex ×1