Shopware 6-如何在SW6的插件系统配置中添加按钮组件

问题描述

我想在插件系统配置页面上具有按钮组件或target

有人知道如何将其添加input-type=button

我浏览了Shopware Core System Config Schema的主文件-

但是config.xml没有任何与按钮相关的东西。

type

解决方法

简短的回答:您不能。

长答案: 您可以通过config.xml中的组件类型生成任何vue-js组件

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/shopware/platform/master/src/Core/System/SystemConfig/Schema/config.xsd">
    <card>
        <title>#Test# Settings</title>

        <component name="sw-button">
            <name>button</name>
            <variant>primary</variant>
        </component>
    </card>
</config>

您分配的每个选项(名称除外)都会作为prop传递给组件。 但是,sw按钮的问题在于,文本是通过默认槽指定的,而默认槽不能作为道具传递。因此,不幸的是,您无法通过config.xml创建按钮

但是无论如何这确实很有意义,因为您无法控制无需任何vue-js就能执行的动作。最简单的方法是创建自己的vue-js模块。