Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework 为什么离子成分会导致<;主机>;然后在里面,这个<;标记类型>;,而不仅仅是渲染<;标记类型>;?_Ionic Framework_Web Component - Fatal编程技术网

Ionic framework 为什么离子成分会导致<;主机>;然后在里面,这个<;标记类型>;,而不仅仅是渲染<;标记类型>;?

Ionic framework 为什么离子成分会导致<;主机>;然后在里面,这个<;标记类型>;,而不仅仅是渲染<;标记类型>;?,ionic-framework,web-component,Ionic Framework,Web Component,参考文档,我看到组件呈现,然后在内部呈现。我想知道背后的原因是什么 例如,为什么不只渲染 除了这个问题,我还看到所有类都附加到,而不是。我也想知道这背后的原因是什么。为什么不直接将类添加到 这是爱奥尼亚按钮组件的tsx: return ( <Host onClick={this.handleClick} aria-disabled={disabled ? 'true' : null} class={{ ...c

参考文档,我看到组件呈现
,然后在
内部呈现。我想知道背后的原因是什么

例如,为什么不只渲染

除了这个问题,我还看到所有类都附加到
,而不是
。我也想知道这背后的原因是什么。为什么不直接将类添加到

这是爱奥尼亚按钮组件的tsx:

return (
      <Host
        onClick={this.handleClick}
        aria-disabled={disabled ? 'true' : null}
        class={{
          ...createColorClasses(color),
          [mode]: true,
          [buttonType]: true,
          [`${buttonType}-${expand}`]: expand !== undefined,
          [`${buttonType}-${finalSize}`]: finalSize !== undefined,
          [`${buttonType}-${shape}`]: shape !== undefined,
          [`${buttonType}-${fill}`]: true,
          [`${buttonType}-strong`]: strong,

          'button-has-icon-only': hasIconOnly,
          'button-disabled': disabled,
          'ion-activatable': true,
          'ion-focusable': true,
        }}
      >
        <TagType
          {...attrs}
          class="button-native"
          disabled={disabled}
          onFocus={this.onFocus}
          onBlur={this.onBlur}
        >
          <span class="button-inner">
            <slot name="icon-only"></slot>
            <slot name="start"></slot>
            <slot></slot>
            <slot name="end"></slot>
          </span>
          {mode === 'md' && <ion-ripple-effect type={this.rippleType}></ion-ripple-effect>}
        </TagType>
      </Host>
    );
<ion-button size="small" class="ios button button-small button-solid ion-activatable ion-focusable hydrated">Default</ion-button>

#shadow-root

<button type="button" class="button-native">
    <span class="button-inner">
        <slot name="icon-only"></slot>
        <slot name="start"></slot>
        <slot></slot>
        <slot name="end"></slot>
    </span>
</button>
返回(
{mode==='md'&&}
);
这就是它的呈现方式:

return (
      <Host
        onClick={this.handleClick}
        aria-disabled={disabled ? 'true' : null}
        class={{
          ...createColorClasses(color),
          [mode]: true,
          [buttonType]: true,
          [`${buttonType}-${expand}`]: expand !== undefined,
          [`${buttonType}-${finalSize}`]: finalSize !== undefined,
          [`${buttonType}-${shape}`]: shape !== undefined,
          [`${buttonType}-${fill}`]: true,
          [`${buttonType}-strong`]: strong,

          'button-has-icon-only': hasIconOnly,
          'button-disabled': disabled,
          'ion-activatable': true,
          'ion-focusable': true,
        }}
      >
        <TagType
          {...attrs}
          class="button-native"
          disabled={disabled}
          onFocus={this.onFocus}
          onBlur={this.onBlur}
        >
          <span class="button-inner">
            <slot name="icon-only"></slot>
            <slot name="start"></slot>
            <slot></slot>
            <slot name="end"></slot>
          </span>
          {mode === 'md' && <ion-ripple-effect type={this.rippleType}></ion-ripple-effect>}
        </TagType>
      </Host>
    );
<ion-button size="small" class="ios button button-small button-solid ion-activatable ion-focusable hydrated">Default</ion-button>

#shadow-root

<button type="button" class="button-native">
    <span class="button-inner">
        <slot name="icon-only"></slot>
        <slot name="start"></slot>
        <slot></slot>
        <slot name="end"></slot>
    </span>
</button>
默认值
#影子根
如您所见,这些类插入到主机(ion按钮)上,而不是
上。我想了解这一决定背后有什么好处


另外,我想了解在
(按钮)内有
的原因是什么?为什么不直接把
扔进


我不熟悉模具和离子,我非常渴望了解构建组件的最佳方法。因此,如果有人能帮助我理解这些描述背后的原因,我将不胜感激

Host
用于在
ion按钮上添加类、事件侦听器和属性,而不是组件的任何嵌套DOM。这是因为在执行类绑定之类的操作时,我们真正关心的是元素本身,而不是组件的内部。使用跨组件通信和影子DOM,在这种情况下不可能获得像
TageType
这样的内部引用


设置此窗口的原因是为了处理跨浏览器在按钮文本/样式应用方式上的差异。爱奥尼亚为我们提供更多的内部知识,而不是其他人需要知道的东西

Host
用于在
ion按钮上添加类、事件侦听器和属性,而不是组件的任何嵌套DOM。这是因为在执行类绑定之类的操作时,我们真正关心的是元素本身,而不是组件的内部。使用跨组件通信和影子DOM,在这种情况下不可能获得像
TageType
这样的内部引用


设置此窗口的原因是为了处理跨浏览器在按钮文本/样式应用方式上的差异。爱奥尼亚为我们提供更多的内部知识,而不是其他人需要知道的东西

谢谢哈廷顿!我还是不明白spa里面的槽的东西。。。我知道每个浏览器都有自己的按钮元素样式。话虽如此,该按钮仍将采用浏览器样式。例如,如果Firefox为按钮提供了红色边框,尽管插槽在里面,但红色边框仍然可见,因为按钮仍然在那里。这有意义吗?顺便问一下,对按钮和其他元素应用重置样式不是更好的方法吗?还有一件事。按钮上的按钮本机类用于什么?真正形成互动/参与。还有更多的事情dev不需要担心。谢谢mhattington!我还是不明白spa里面的槽的东西。。。我知道每个浏览器都有自己的按钮元素样式。话虽如此,该按钮仍将采用浏览器样式。例如,如果Firefox为按钮提供了红色边框,尽管插槽在里面,但红色边框仍然可见,因为按钮仍然在那里。这有意义吗?顺便问一下,对按钮和其他元素应用重置样式不是更好的方法吗?还有一件事。按钮上的按钮本机类用于什么?真正形成互动/参与。还有更多的事情dev不需要担心。