I'm writing a Vue Native app and have attempted to use event.target.reset()
to reset fields to their original values when the app loads, per @Vladimir Salguero's post which applies to VueJS in this thread. However, this causes the following error message to appear on the phone when the reset button is pressed: TypeError: event.target.reset is not a function. (In 'event.target.reset()', 'event.target.reset' is undefined)
Here is the reset method which is located in the <script>
tags:
export default {
methods: {
reset(event) {
// console.log(event);
event.target.reset();
}
}
}
Here is how it's being called from within the <template>
tags:
<nb-col>
<nb-button rounded :onPress="reset">
<nb-text>Reset</nb-text>
</nb-button>
</nb-col>
[Native Base is also being used for UI components, thus the nb
prefixes within the tags].
When the // console.log(event);
line within the reset()
method is enabled, it displays the following information in the console:
Class {
"_dispatchInstances": FiberNode {
"tag": 5,
"key": null,
"type": "RCTView",
},
"_dispatchListeners": [Function bound touchableHandleResponderRelease],
"_targetInst": FiberNode {
"tag": 5,
"key": null,
"type": "RCTView",
},
"bubbles": undefined,
"cancelable": undefined,
"currentTarget": 435,
"defaultPrevented": undefined,
"dispatchConfig": Object {
"dependencies": Array [
"topTouchCancel",
"topTouchEnd",
],
"registrationName": "onResponderRelease",
},
"eventPhase": undefined,
"isDefaultPrevented": [Function functionThatReturnsFalse],
"isPropagationStopped": [Function functionThatReturnsFalse],
"isTrusted": undefined,
"nativeEvent": Object {
"changedTouches": Array [
[Circular],
],
"identifier": 0,
"locationX": 41,
"locationY": 12,
"pageX": 226,
"pageY": 433,
"target": 433,
"timestamp": 6019178,
"touches": Array [],
},
"target": 433,
"timeStamp": 1584151959763,
"touchHistory": Object {
"indexOfSingleActiveTouch": 0,
"mostRecentTimeStamp": 6019178,
"numberActiveTouches": 0,
"touchBank": Array [
Object {
"currentPageX": 226,
"currentPageY": 433,
"currentTimeStamp": 6019178,
"previousPageX": 226,
"previousPageY": 433,
"previousTimeStamp": 6019176,
"startPageX": 226,
"startPageY": 433,
"startTimeStamp": 6019103,
"touchActive": false,
},
],
},
"type": undefined,
}
Apparently, there is no reset
within this event. So, how can all of the fields in the app be reset automatically WITHOUT adding code to manually reset each field?