<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.active {color: red;}
</style>
</head>
<body>
<div id="app">
<router-view></router-view>
</div>
<script crossorigin="anonymous" integrity="sha384-+jvb+jCJ37FkNjPyYLI3KJzQeD8pPFXUra3B/QJFqQ3txYrUPIP1eOfxK4h3cKZP" src="https://lib.baomitu.com/vue/2.6.11/vue.js"></script>
<script crossorigin="anonymous" integrity="sha384-+Asl5rl/8/miQUCzICBPdaU116UU0E8qRK2yW+GGWm9Gl5amVsmF59QiSnOnFxv7" src="https://lib.baomitu.com/vue-router/3.1.3/vue-router.js"></script>
<script>
const List = Vue.component('List', {
template: `
<div>
<nav @click="toggleTab">
<span :class="{active: tab=='hot'}" data-tab="hot">热门</span>
<span :class="{active: tab=='question'}" data-tab="question">问题</span>
<span :class="{active: tab=='video'}" data-tab="video">视频</span>
<span :class="{active: tab=='consulting'}" data-tab="consulting">咨询</span>
</nav>
<router-link to="/detail">detail page</router-link>
</div>
`,
computed: {
tab() {
return this.$route.query.tab || 'hot'
},
},
methods: {
toggleTab(e) {
this.$router.replace({query: {tab: e.target.dataset.tab||'hot'}});
}
},
});
const Detail = Vue.component('Detail', {
template: '<p>this is detail page</p>'
})
const router = new VueRouter({
routes: [
{path: '/', redirect: '/list'},
{path: '/list', component: List},
{path: '/detail', component: Detail}
]
})
var vm =new Vue({
el: '#app',
router,
})
</script>
</body>
</html>
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |