npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue-timezone-select

v1.0.3

Published

vue timezone select

Downloads

313

Readme

前置依赖

必须

vue3.0

非必须

Element-plus

npm install -S element-plus vue3

安装 Element-plus 之后 需要自行注册 ElSelectElOption 两个组组件,才可以直接使用内置组件,如果不使用 Element-plus 库,可以使用 hooks 方法获取数据,然后使用其他组件库的选择器组件

组件使用

npm install -S vue-timezone-select

Props

type Props = {
  modelValue: string // 绑定值 v-model
  labelStyle?: ILabelStyle // 展示内容格式
  timezones?: ICustomTimezone // 时区数据
  filterable?: boolean // 是否开启筛选
  placeholder?: string 
}

/**
 * key:   "Pacific/Midway"        选中是绑定的值 
 * value: "Midway Island, Samoa"  选中时展示的内容
 * key - 更多时区配置 可参考 https://github.com/dmfilipenko/timezones.json
 */
type ICustomTimezone = {
  [key: string]: string
}

type ILabelStyle = "original" | "altName" | "abbrev"

Event

type ITimezoneOption = {
  value: string
  label: string
  abbrev?: string
  altName?: string
  offset?: number
}

change(info: ITimezoneOption) => void

使用示例

使用 Element-plus


<script setup lang="ts">
import { ref } from "vue";
import TimeSelect, { ITimezoneOption } from "vue-timezone-select";

const localValue = ref("");
const selectInfo = ref({});
const labelStyle = "original"; // original abbrev altName

const timezones = ref({
  "Pacific/Midway": "Midway Island, Samoa",
  "America/Tijuana": "Tijuana",
  "Asia/Almaty": "Almaty, Novosibirsk", 
});

function changeHandle(val: ITimezoneOption) {
  selectInfo.value = val;
}
</script>

<template>
  <div class="play-container">
    <div style="width: 500px">
      <TimeSelect
        placeholder="please select your timezone"
        :label-style="labelStyle"
        v-model="localValue"
        filterable
        @change="changeHandle"
      ></TimeSelect>

      <div style="height: 20px; padding: 10px 0">selected value:{{ localValue }}</div>
      <div style="height: 150px">selected info: {{ selectInfo }}</div>
    </div>
  </div>
</template>

使用其他组件库,获取到数据,使用组件库自身的选择器组件


<script setup lang="ts">
import { ref } from "vue";
import { useTimezoneSelect } from "vue-timezone-select";

// 使用 hook 方法
const otherValue = ref("");
const otherInfo = ref({});
const otherLabelStyle = ref("altName"); // original abbrev altName
const { timezoneOptions: otherOptions, getSelectedInfo } = useTimezoneSelect({
  labelStyle: otherLabelStyle,
  timezones,
});
function otherChangeHandle(val: string) {
  otherInfo.value = getSelectedInfo(val, otherOptions);
}
</script>

<template>
  <div class="play-container">
    <div style="width: 500px">
      <div style="height: 20px; padding: 10px 0">选中值:{{ localValue }}</div>
      <el-select
        style="width: 100%"
        filterable
        v-model="otherValue"
        @change="otherChangeHandle"
      >
        <template v-for="item in otherOptions" :key="item.value">
          <el-option :label="item.label" :value="item.value"></el-option>
        </template>
      </el-select>
      <div style="height: 150px">详细信息: {{ otherInfo }}</div>
    </div>
  </div>
</template>