Giter Site home page Giter Site logo

Comments (4)

jc9702507 avatar jc9702507 commented on June 11, 2024

这个可能是用法问题,ValuesChange不要多次绑定,可发下js

from ant-design-mini.

zhangpiao96 avatar zhangpiao96 commented on June 11, 2024

import {
Form
} from 'antd-mini-v1/es/Form/form';

Page({
data: {
position: 'horizontal',
},
form: new Form(),

onReady() {
this.form.onValuesChange((changedValues, allValues) => {
console.log(changedValues);
});
},

handleRef(ref) {
this.form.addItem(ref);
},

reset() {
this.form.reset();
},

toggle() {
this.setData({
position: this.data.position === 'horizontal' ? 'vertical' : 'horizontal',
});
},

async submit() {
const values = await this.form.submit();
my.alert({
title: '提交',
content: JSON.stringify(values),
});
}
});

我会反复操作:跳转这个界面,返回,再跳转,就是导致多次绑定了,那我该怎么绑定呢

from ant-design-mini.

jc9702507 avatar jc9702507 commented on June 11, 2024

这个应该是钉钉小程序中的问题:页面跳转了,但是小程序页面还没有被unLoad,再次进入页面,调用了onReady。
你可以尝试这样解决:

import { Form } from 'antd-mini-v1/es/Form/form';

Page({
  data: {
    position: 'horizontal',
  },
  
  onShow() {
    this.form = new Form();
    this.form.onValuesChange((changedValues, allValues) => {
      console.log(changedValues);
    });
  },
  
  handleRef(ref) {
    this.form.addItem(ref);
  },
  
  reset() {
    this.form.reset();
  },
  
  toggle() {
    this.setData({
      position: this.data.position === 'horizontal' ? 'vertical' : 'horizontal',
    });
  },
  
  async submit() {
    const values = await this.form.submit();
    my.alert({
      title: '提交',
      content: JSON.stringify(values),
    });
  }
});

from ant-design-mini.

zhangpiao96 avatar zhangpiao96 commented on June 11, 2024

可以了,谢谢

from ant-design-mini.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.