类人:
@Data
public class Person<T extends Parent> implements Serializable {
private static final long serialVersionUID = 7822965786010192978L;
private static final ObjectMapper objectMapper = new ObjectMapper();
private String id;
private T people; // change (String peopleInfo) to object extends Parent after read data from database
private String peopleInfo; // change (T people) to string and save in the dataBase as an string
@SneakyThrows
public void setPeople(T people) {
this.people = people;
peopleInfo = objectMapper.writeValueAsString(people);
}
@SneakyThrows
public void setPeopleInfo(String peopleInfo) { …Run Code Online (Sandbox Code Playgroud) 在 Vue 组件中:
import { someRequestMethod } from '@/api/requ'
...
methods: {
testMethod() {
someRequestMethod(someRequestData).then(function() {
this.outMethod_01()
}).then(function() {
this.outMethod_02()
})
}
outMethod_01() {
console.log('I am an outer method 01.');
}
outMethod_02() {
console.log('I am an outer method 02.');
}
}
Run Code Online (Sandbox Code Playgroud)
当我打电话时testMethod,有Promise回应。然后我想调用outMethod_01如果成功,outMethod_02如果有错误。但我有错误outMethod_01 is undefined和outMethod_02 is undefined。
那么如何调用外部方法Promise呢?