我正在尝试制作一个递归组件,充当一种树视图,其中该组件接受一个数组。
App.svelte
<script>
import Tree from "./Tree.svelte"
let name = 'world';
</script>
<Tree arrayTree={[1, 2, [3, 4], 5, 6, 7, [8, [9, 10]], 11, 12]}/>
Run Code Online (Sandbox Code Playgroud)
Tree.svelte
<script>
export let arrayTree = []
export let level = 0
</script>
{#each arrayTree as branch}
{#if Array.isArray(branch)}
<!-- How do I do this? -->
{:else}
<p>{'-'.repeat(level)}{branch}</p>
{/if}
{/each}
Run Code Online (Sandbox Code Playgroud)
我的目标是重新渲染内部组件,但我无法<Tree>在组件内部重新调用,否则它会显示:Tree is not defined。有什么办法可以实现这个目标吗?
我想使用Id我在其中使用函数的元素作为参数。例子:
<div
class="col-2 column-center"
id="myId"
@mouseover="aFunction(id)"
>
methods: {
aFunction(id){
alert(id);
}
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用。我该怎么做?
我想同时运行两个 sql 查询,这样我就不必运行两次才能获得结果
SELECT COUNT(*) FROM attendance WHERE month =10 and grade = 4
SELECT COUNT(*) from attendance WHERE month = 10 and grade = 4 AND userid = 24 and attendance = 'present'
Run Code Online (Sandbox Code Playgroud)
我想要两个总班级数和学生出席的班级总数。
想象一下使用微服务的 OAuth 提供商。我们将为授权端点、令牌端点等提供微服务。
For example, every endpoint is different microservice and most endpoints will need to retrieve client by id to authenticate request. So how should I share method to get client from database, model for client and all related to it entities?
How shall I share common methods and classes between microservices?
If microservice A depends on microservice B, then I need to do communication between them over HTTP or I just can add project reference? Or maybe situation …