我有一个父组件,我需要调用其子组件之一中存在的方法:
<template>
<div>
<button @click="callChildMethod">
<child-component ref="child" />
</div>
</template>
<script>
setup(props) {
const child = ref(null)
const callChildMethod = () => {
child.doSomething()
}
return {
child,
callChildMethod
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
子组件包含doSomething方法:
const doSomething = () => { console.log('calling method....') }
Run Code Online (Sandbox Code Playgroud)
由于我使用的是 VueJS3 和 Composition API,因此我的方法是使用模板引用来调用子组件中的方法。显然不起作用,但我看不出我错过了什么。有人对这个有线索吗?提前致谢
javascript vue.js vuejs3 vue-composition-api vue-script-setup
我需要在我的laravel项目中添加一个新列,没问题,我用它Schema::table()来更新,没关系.现在我需要找出我在这个表上有多少记录并更新一些值.
我有桌子Warrants:
Schema::create('warrant_grants', function(Blueprint $table) {
$table->increments('id');
$table->integer('warrant_plan_id');
$table->integer('shareholder_id');
});
Run Code Online (Sandbox Code Playgroud)
所以我使用新的迁移文件创建了新字段:
Schema::table('warrant_grants',function ($table) {
$table->string('name',100);
});
Run Code Online (Sandbox Code Playgroud)
现在我需要name使用一些值更新表中的这个字段,例如,如果表有100条记录,那么我需要在每一行中插入值"Warrant-X",其中X是以1到100开头的数字.例:
Warrant-1,Warrant-2,.... Warrant-100.
我花了几个小时寻找一些方法来使用种子,但我没有找到.所以基本上我有两个问题: