小编Stu*_*Stu的帖子

如何在 svelte 中(递归地)在其自己的组件中渲染组件?

我正在尝试制作一个递归组件,充当一种树视图,其中该组件接受一个数组。

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。有什么办法可以实现这个目标吗?

精简 REPL

recursion svelte

6
推荐指数
1
解决办法
1242
查看次数

如何使用 Vue.js 中的函数选择元素 ID?

我想使用Id我在其中使用函数的元素作为参数。例子:

<div
    class="col-2 column-center"              
    id="myId"              
    @mouseover="aFunction(id)"              
>

methods: {    
    aFunction(id){
      alert(id);
    }
 }
Run Code Online (Sandbox Code Playgroud)

但它不起作用。我该怎么做?

vue.js vuejs2

0
推荐指数
1
解决办法
65
查看次数

如何同时运行两个 SQL 查询?

我想同时运行两个 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)

我想要两个总班级数和学生出席的班级总数。

mysql sql

0
推荐指数
1
解决办法
56
查看次数

实施微服务架构,管理其相互依赖关系

想象一下使用微服务的 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 …

c# domain-driven-design microservices

0
推荐指数
1
解决办法
246
查看次数