我正在try 在Laravel中实现此Vue Word Cloud组件的TE自定义呈现器: https://github.com/SeregPie/VueWordCloud

我首先使用php准备我的单词数组(正在工作):

        @php
            $tags = App\Models\Tag::withCount('songs')->orderBy("songs_count", "desc")->take(50)->get();
            $words = "";
            foreach($tags as $tag)
            {
                $count = $tag->countSongs();
                $words .= "['$tag->name', $count],";
            }
        @endphp

然后我加上了云这个词(这是有效的)

    <vue-word-cloud
        style="
            height: 480px;
            width: 80%;
            margin: 0 auto;
        "
        :words="[{{ $words }}]"
        :color="([, weight]) => weight > 40 ? 'Red' : weight > 30 ? 'Orange' : weight > 20 ? 'Seagreen' : weight > 10 ? 'White' : weight > 5 ? 'LightSkyBlue ' : 'White'"
        font-family="Nunito"
    >   
    
    </vue-word-cloud>

但是当我try 像这样使用自定义渲染器时:(我需要这个来在每个单词周围加上一个链接)

    <vue-word-cloud
        style="
            height: 480px;
            width: 80%;
            margin: 0 auto;
        "
        :words="[{{ $words }}]"
        :color="([, weight]) => weight > 40 ? 'Red' : weight > 30 ? 'Orange' : weight > 20 ? 'Seagreen' : weight > 10 ? 'White' : weight > 5 ? 'LightSkyBlue ' : 'White'"
        font-family="Nunito"
    >   
      <template slot-scope="{text, weight, word}">
        <div>
          @{{ text }} <!-- this is not working, I need a link around the word here -->
        </div>
      </template>       
    </vue-word-cloud>

它会产生以下错误:

[Vue warn]: Property "text" was accessed during render but is not defined on instance. 

我绝对不是VUE.js专家,也许我错过了一些微不足道的东西. 如何访问自定义呈现器的"Word"变量

推荐答案

slot-scope的语法是deprecated since v2.6.请改用v-slot:

<template v-slot="{text, weight, word}">

Php相关问答推荐

如何在Laravel Controller中存储文本区域值?

打印SQL表内容时在DIV内添加断点

如何发送woocommerce订单跟踪码与短信

PHP Array to Powershell exec命令Args

Woocommerce自定义变体html表仅显示带值的列

PHP:从数组中获取唯一的数字组合

从目录文件夹中获取文件并追加到 Select 下拉列表(选项)-wordpress/wc

将WooCommerce WC_Order对象与wp_Schedule_Event一起使用

PHP:使用FORT从数据库获取USERS表到AUTH表

HTAccess重写一些URL,但将所有其他URL发送到另一个页面

如何批量处理消息总线中的消息

如果所有请求都通过index.php路由,如何使用htaccess文件强制使用HTTPS?

对 WooCommerce 购物车和 checkout 中显示的运输方式进行排序

将一个表中的行连接为不同表MYSQL中的一列

添加产品标签以通过 WooCommerce 邮箱通知订购商品

PHP / DOM : 解析 HTML 以提取基于类的数​​据

如何在不解压缩/重新压缩的情况下连接(连接)两个缩小的值

转发和非转发呼叫 - 后期静态绑定

如何将在同一台服务器上运行的 2 个 PHP 应用程序与使用公共会话分开

如何简化 php API 中的格式化数组列表数据以提供 React Native 部分列表