Skip to content

Instantly share code, notes, and snippets.

View letswritetw's full-sized avatar
🎯
Focusing

Let's Write - August letswritetw

🎯
Focusing
View GitHub Profile
@letswritetw
letswritetw / vue3-composition-api-props-getData.js
Last active August 24, 2022 12:42
vue3-composition-api-import
import { ref } from 'vue'
export default function(uri) {
const data = ref(null);
const getData = async () => {
try {
const result = await fetch(uri);
if(!result.ok) {
@letswritetw
letswritetw / vue3-composition-api-getData.js
Last active August 24, 2022 12:42
vue3-composition-api-import
import { ref } from 'vue'
export default function() {
const users = ref(null);
const getData = async () => {
try {
const data = await fetch('https://jsonplaceholder.typicode.com/users');
if(!data.ok) {
@letswritetw
letswritetw / vue-composition-api-ref.vue
Last active August 24, 2022 12:39
vue-composition-api
<template>
<div>
<p ref="msg"></p>
<button type="button"
@click="changeMsg">click me</button>
</div>
</template>
<script>
import { ref } from 'vue'
// 登入
liff.login({
// 使用者登入後要去到哪個頁面
redirectUri: 'https://www.xxxxxxx.com.tw'
});
// 登出
liff.logout();
@letswritetw
letswritetw / liff-init.js
Last active August 16, 2022 11:33
liff-init
var liffID = 'XXXXXXXXXXXX';
liff.init({
liffId: liffID
}).then(function() {
console.log('LIFF init');
// 這邊開始寫使用其他功能
}).catch(function(error) {
@letswritetw
letswritetw / leaflet-osm-basic-map.js
Last active July 26, 2022 02:25
leaflet-osm-basic
// *** 放置地圖
let zoom = 17; // 0 - 18
let center = [xxx, xxx]; // 中心點座標
let map = L.map('map').setView(center, zoom);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap', // 商用時必須要有版權出處
zoomControl: true , // 是否秀出 - + 按鈕
}).addTo(map);
const customIcon = L.icon({
iconUrl: '圖片的 URL',
iconSize: [42, 42],
});
const marker = L.marker(center, {
icon: customIcon,
title: '跟 <a> 的 title 一樣', // 跟 <a> 的 title 一樣
opacity: 1.0
}).addTo(map);
@letswritetw
letswritetw / leaflet-osm-basic-auth.js
Last active July 26, 2022 02:03
leaflet-osm-basic
// 跟使用者要位置
function successGPS(position) {
const lat = position.coords.latitude;
const lng = position.coords.longitude;
center = [lat, lng];
// 接著寫確認了座標後要執行的事
};
function errorGPS() {
window.alert('無法判斷您的所在位置,無法使用此功能。預設地點將為 台北市動物園');
// 接著寫使用者「封鎖」位置資訊請求後要執行的事
@letswritetw
letswritetw / youtube-iframe-api-custom.html
Last active March 18, 2022 04:10
youtube-iframe-api
<div class="embed-responsive embed-responsive-16by9">
<iframe id="player" src="https://www.youtube.com/embed/M7lc1UVf-VE?enablejsapi=1&allowsInlineMediaPlayback=true&playsinline=1"></iframe>
</div>
<!-- 播放相關按鈕-->
<div class="row align-items-center pt-4">
<div class="col text-center">
<div class="btn-group">
<button class="btn btn-outline-dark" id="play" type="button">播放</button>
<button class="btn btn-outline-dark" id="pause" type="button">暫停</button>
@letswritetw
letswritetw / tailwind-selflist.js
Last active February 17, 2022 03:03
tailwind
module.exports = {
purge: {
// 哪些檔案要編譯
content: ['./public/**/*.html', './src/**/*.vue'],
// 哪些 class 是白名單
options: {
safelist: ['bg-red-500', 'px-4'],
}
},