Last active
November 28, 2019 00:21
-
-
Save milkmidi/c9fcc1450d1779bfac0467b41d517016 to your computer and use it in GitHub Desktop.
DebugComponent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 本機開發用,點了可以直接開 vscode | |
*/ | |
interface Props { | |
path: string | |
} | |
export default { | |
name: 'DebugComponent', | |
functional: true, | |
props: { | |
path: { | |
type: String, | |
required: true, | |
}, | |
}, | |
render(createElement, { props }) { | |
if (process.env.NODE_ENV !== 'development') { | |
alert('👿 Development mode only'); | |
return null; | |
} | |
const { path }:Props = props; | |
const click = () => fetch(`/__open-in-editor?file=${path}`); | |
const fileName:string = path.split('/').pop(); | |
return createElement('div', | |
{ | |
class: '🤜😝🤛', | |
style: { | |
cursor: 'pointer', | |
background: '#c0392b', | |
padding: '10px', | |
borderRadius: '10px', | |
color: 'white', | |
fontSize: '24px', | |
}, | |
on: { click }, | |
}, | |
[fileName]); | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
export default { | |
name: 'Rockroll', | |
mounted() { | |
console.log('hi rockroll'); | |
}, | |
}; | |
</script> | |
<template lang="pug"> | |
.rockroll | |
if DEV_MODE | |
DebugComponent(path="components/Rockroll.vue") | |
h1 Rockroll 🤘 | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment