初めまして。よろしくお願いいたします。
質問
件名の構成で、class内のconstructorで自身のメソッド呼び出しにより自身のメンバを設定したいのですが、this.メンバがundefinedになってしまい動作しません。
コードが間違っているのか、そもそもできないのか、ご教示いただければ幸いです。
単一ファイルコンポーネントのコード:
<template>
<div id="mapSelector">
{{ strcopy }}
</div>
</template>
<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
@Component({
props: {
propinfos: Array
}
})
export default class MapSelector extends Vue {
propinfos: string[]
infos = this.propinfos;
str: string;
strcopy: string;
constructor() {
super();
this.str = "hello";
copystr();
}
copystr() {
this.strcopy = this.str;
}
}
</script>
<style scoped>
</style>
サブ質問
上記の単一ファイルコンポーネントをjsFiddle上で動かしたいのですが、恥ずかしながらやり方が分かりませんでした。こちらもご教示いただけると助かります。