I am pretty new to vue.js, so I'm not even sure if what I'm trying to do is possible. I am working on developing a Matrix component that I could then use in other applications. My problem is that I would like for the getIdentity() method to return a new Matrix component with an array passed into it
export default {
name: 'Matrix',
props: {
initRows: Number,
initColumns: Number,
initValues: Array
},
data () {
return {
editable: true,
contents: [],
rows: 1,
columns: 1
}
},
created () {
...
},
methods: {
addColumn () {...},
removeColumn (column) {...},
addRow () {...},
removeRow (row) {...},
getRREF () {...},
getInverse () {...},
getIdentity () {
if (this.rows === this.columns) {
let tempMtx = [];
for (let row = 0; row < this.rows; row++) {
tempMtx[row] = [];
for (let col = 0; col < this.columns; col++) {
tempMtx[row][col] = row === col ? 1 : 0;
}
}
return new Matrix({propsData: {initValues: tempMtx}}); // This is the part I can't figure out
} else {
throw new Error('Rows and Columns must be equal to get the identity matrix');
}
}
}
}
I ended up figuring it out with a bit of help from this article . Except that instead of importing it from another file, I just defined let MatrixConstructor = vue.extend(this.a);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.