Skip to content
Discussion options

You must be logged in to vote

你好,SoberJS是用原生JS写的组件,而 ofa.js 内的模板绑定语法,只适用于基于 ofa.js 开发的组件,所以 s-search 组件可能要重新包装成 ofajs的组件才能用模板语法。

比如我这里重新包装一下 s-search 为 w-search:

w-search.html

<template component>
  <s-search
    attr:placeholder="placeholder"
    on:input="value = $event.target.value"
  >
    <slot name="start" slot="start"></slot>
    <slot></slot>
  </s-search>
  <script>
    export default async () => {
      return {
        tag: "w-search",
        attrs: {
          placeholder: null,
        },
        data: {
          value: "",
        },
        watch: {
          value() {
            if (this.shadow.$("s-search").ele.value !== this.value) {
              this.shadow.$("s-search").ele.value = this.value;

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by cyb233
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@cyb233
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants