Frontend Engineer
yubinbango-core2を使います。
https://www.npmjs.com/package/yubinbango-core2
npm install yubinbango-core2
<template> <input type="text" v-model="zipcode" placeholder="郵便番号"/> </template> <script lang="ts"> import Vue from 'vue' import YubinBango from 'yubinbango-core2' type AddressByYubinBango = { 'region_id': number, region: string, locality: string, street: string, extended: string, } export default Vue.extend({ data() { return { info: { zipcode: '', prefecture: '', city: '', } } }, computed: { zipcode: { get(): string { return this.info.zipcode }, set(zipcode: string) { this.info = {...this.info, zipcode} if (zipcode.length === 7) { const self = this const _ = new YubinBango.Core(zipcode, function (address: AddressByYubinBango) { self.info = { ...this.info, prefecture: address.region, city: address.locality + address.street } }) } } }, } }) </script>
yubinbango-core2を使います。
https://www.npmjs.com/package/yubinbango-core2
npm install yubinbango-core2
<template> <input type="text" v-model="zipcode" placeholder="郵便番号"/> </template> <script lang="ts"> import Vue from 'vue' import YubinBango from 'yubinbango-core2' type AddressByYubinBango = { 'region_id': number, region: string, locality: string, street: string, extended: string, } export default Vue.extend({ data() { return { info: { zipcode: '', prefecture: '', city: '', } } }, computed: { zipcode: { get(): string { return this.info.zipcode }, set(zipcode: string) { this.info = {...this.info, zipcode} if (zipcode.length === 7) { const self = this const _ = new YubinBango.Core(zipcode, function (address: AddressByYubinBango) { self.info = { ...this.info, prefecture: address.region, city: address.locality + address.street } }) } } }, } }) </script>