encapsulate a public method, and then introduce this file in other pages to call it, always reporting Error in callback for watcher "list": "TypeError: Object (...) is not a function" found in
// publicarray-merge.js
export default function steamroller(arr) {
const newArr = [];
for (let i = 0; i < arr.length; iPP) {
if (Array.isArray(arr[i])) {
newArr.push(...steamroller(arr[i]));
} else {
newArr.push(arr[i]);
}
}
return newArr;
}
// ,
import { steamroller } from "../public/array-merge.js";
data() {
return {
filterOrderItems: [],
};
},
methods: {
list() {
this.filterOrderItems = steamroller(this.OrderItems);
}
}