Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

props update 比较时 出现的两个问题 #103

Open
wsm1025 opened this issue May 25, 2023 · 3 comments
Open

props update 比较时 出现的两个问题 #103

wsm1025 opened this issue May 25, 2023 · 3 comments

Comments

@wsm1025
Copy link

wsm1025 commented May 25, 2023

Q1

import { h, ref } from "mini-vue.esm-bundler.js";
export const App = {
  name: "APP",
  render() {
    return h("div", { id: "root", ...this.props }, [
      h(
        "button",
        {
          onClick: this.change1,
        },
        "修改值修改"
      ),
    ]);
  },
  setup() {
    const props = ref({a:10});
    const change1 = () => {
      props.value.foo = "new foo";
    };
    return {
      change1,
      props,
    };
  },
};

点击按钮时
error:  dep is not iterable (cannot read property undefined)


Q2:
import { h, ref } from "mini-vue.esm-bundler.js";
export const App = {
  name: "APP",
  render() {
    return h("div", { id: "root", ...this.props }, [
      h(
        "button",
        {
          onClick: this.change1,
        },
        "修改值修改"
      ),
    ]);
  },
  setup() {
    const props = ref({ });
    const change1 = () => {
      props.value.foo = "new foo";
    };
    return {
      change1,
      props,
    };
  },
};

点击修改时更改的按钮
这时候 按理说 props 改变了 视图应该更新,但因为 之前没有收集到依赖,视图没有重新渲染
@viacooter
Copy link

viacooter commented May 25, 2023 via email

@MachoManCk
Copy link

Well, since there's no reply, let's all go

@viacooter
Copy link

viacooter commented May 29, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants