如果資料有誤或未及更新,發個 issue 給我吧
安裝依賴
npm install
或
yarn install
編譯
npm run build
或
npm run watch
Local server
npm run start
台灣縣市二聯式選單 http://dennykuo.github.io/tw-city-selector
Home Page: tw-city-selector.vercel.app
如果資料有誤或未及更新,發個 issue 給我吧
安裝依賴
npm install
或
yarn install
編譯
npm run build
或
npm run watch
Local server
npm run start
請問授權方式?是完全免費嗎?
目前使用的 Key 都是 "Country" (有 r )
但如果是台灣的 "縣" 應該翻譯為 "County" (沒有 r)
參考來源:https://en.wikipedia.org/wiki/County_(Taiwan)
預設值若使用 台北市,但 standardWords 為 true 時
在使用的時候使用 js 實例的作法,
但是因為想要把資料傳到 Google 表單裡,
因此 name 的屬性值必須使用跟 Google 表單相同的值,
不知道是否有方法可以插入希望使用的 name 值呢?
<div class="form-item">
<label for="city">城市</label>
<div id="city">
<select name="entry.14110xxxxx" id="county"></select>
<select name="entry.17531xxxxx" id="district"></select>
<input type="text" name="entry.13580xxxxx" id="zip">
</div>
</div>
<script>new TwCitySelector(
{
el: "#city",
elCounty: "#county",
elDistrict: "#district",
elZipcode: "#zip"
});</script>
首先感謝你寫出這麼好用的套件,在網站開發上幫了大忙。因為我是使用node + react開發,融合的時候還稍微摸索了一下,想說或許在文件裡可以增加react使用的說明,方便其他人使用。內容如果有不合適的地方再請你隨意修改,謝謝。
// 以下為Component範例。直接使用也可以。
import React, { Component } from 'react';
// 此為引入,不需要再使用<script></script>引入
import TwCitySelector from 'your/path/node_modules/tw-city-selector/tw-city-selector';
class CitySelector extends Component {
componentDidMount() {
new TwCitySelector({
el: '.my-selector-c',
elCounty: '.county', // 在 el 裡查找 dom
elDistrict: '.district', // 在 el 裡查找 dom
elZipcode: '.zipcode', // 在 el 裡查找 dom
});
}
// 在render()參考「js 實例方式加載」增加相對應element即可
render () {
return (
<div class="my-selector-c">
<div>
<select class="county"></select>
</div>
<div>
<select class="district"></select>
</div>
<div>
<input type="text" class="zipcode">
</div>
</div>
);
}
}
export default CitySelector;
package.json
中應列舉出 Gulp 以及相關的相依套件
假設原本有值(編輯個人資料)
我要讓他預設「selected」好讓我提交可以帶他的值進去
您好,感謝您的程式
一直以來都用chrome作主要的瀏覽器
現在系統在作上線的的測試
發現用IE(11)開啟時會出錯誤
同樣的問題亦出現在github的說明頁裡
https://dennykuo.github.io/tw-city-selector/#/
顯示 物件沒有支援這個屬性或方法 'includes'
大概位在:
function setStandardWords
裡的
if (county.includes(str))
return county.replace(str, newStr);
return county;
不知是否可抽空修正或是提供修正方式?
感謝您
William
建議依據中華郵政官方資料更新,細項如下:
想請教下
關於您所製作的tw-city-selector
全部都透過 div包住了
那要取得使用者點選完的select 的數值要如何取得呢?
感謝您
你好,請問如何正確的SET Value呢??
我用以下方是將county設定上去,設定完成但district卻沒辦法正確顯示
$('.county-select').find("select[name='county']").val(county).change();
var districtSelect = document.getElementById("district"); districtSelect.addEventListener("change", function () { let selectedDistrictIndex = districtSelect.selectedIndex; console.log(selectedDistrictIndex); console.log(document.getElementsByTagName("option")[selectedDistrictIndex].text); }, false);
他會取到county的值
我在使用變數綁定data-value時,用api的回傳把值替換掉,畫面不會跟著響應data-value改變後的值,我嘗試將值帶入select綁定的v-model,區域不會顯示帶入的值
大大你好:
我在使用時發現,一定要將hasZipCode設定為true才能讓zipcode被觸發產生,
好像有看到一段source code是el 跟hasZipCode 擇一都可以,但後來就找不到了,
不過範例裡面是沒有設定hasZipCod的 , 卻是不能work,能否再麻煩大大看看?
感謝!
new TwCitySelector({
el: '.city-selector-set',
elCounty: '.county',
elDistrict: '.district',
elZipcode: '.zipcode',
hasZipcode: true // Must Have
});
依照官方資料
以下內容需修正:
非常感謝這個專案,請問是否有排除特定縣市與鄉鎮的方式呢?
有看到 #11 相關的討論,不知道這個功能是否已經實現了呢?
src/tw-city-selector
line #157
#203
有使用 getCountyOptions
但沒有定義。
應是 line #208
function getCountryOptions
,應改正為 getCountyOptions
選擇縣市,選擇區域
假設我要兩份同樣的在同一個頁面上能怎麼實現?
我發現我把它分開之後
var c1 = new TwCitySelector({
el: ".my-selector-c",
elCounty: ".county",
elDistrict: ".district"
});
var c2 = new TwCitySelector({
el: ".my-selector-cc",
elCounty: ".county_invoice",
elDistrict: ".district_invoice"
});
他兩塊選單的input名字都會是 name="county"
和 district name="district"
?
你好,很感謝提供這個工具!
注意到在高雄市中,鳳山應是區而不是市,可以協助修正這個錯誤嗎?
謝謝!
像城市有onlyCity,是否有限制地區的功能呢?
用SELECT如何預設縣市?謝謝
this.elCounty.querySelector('option:checked').dataset.index; >>Line:281
In options of this plugin, we call district field name as districtFieldName
and zip code field name zipcodeFieldName
, but call country field name as county
FiledName
? Isn't it a typo?
如果選了縣市, 再選了區域, 然後再把區域選擇 "選擇區域"
那麼郵遞區號會顯示 "undefined"
如果顯示成空白會不會比較好一點呢 ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.