vue-city-pinyin
TypeScript icon, indicating that this package has built-in type declarations

2.0.8 • Public • Published

vue-city-pinyin

Development based on webstorm2023 and volar plugin

Install

pnpm add vue-city-pinyin

Preview

color

Example

# main.js

// code...

import cityPinyin from 'vue-city-pinyin';
import 'vue-city-pinyin/dist/index.css';

app.use(cityPinyin);
<script setup lang="ts">
import { ref } from 'vue'

type CityType = {
  id: string
  name: string
}

const startCity = ref<CityType>({
  id: '',
  name: '',
})

const endCity = ref<CityType>({
  id: '',
  name: '',
})

function onChange(item: CityType, type: string) {
  if (type === 'start')
    startCity.value = item
  else
    endCity.value = item
}

function onSubmit() {
  console.log('出发城市', startCity.value);
  console.log('到达城市', endCity.value);
}
</script>

<template>
  <div class="demo">
    <div style="padding: 10px;">
      <div>出发城市</div>
      <city-select :data="startCity" @on-change="onChange($event, 'start')" hot/>
    </div>
    <div style="padding: 10px;">
      <div>到达城市</div>
      <city-select :data="endCity" @on-change="onChange($event, 'end')"/>
    </div>
    <div style="padding: 10px;">
      <button @click="onSubmit">获取城市</button>
    </div>
  </div>
</template>

Package Sidebar

Install

npm i vue-city-pinyin

Weekly Downloads

15

Version

2.0.8

License

MIT

Unpacked Size

239 kB

Total Files

155

Last publish

Collaborators

  • saturn