Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
<script src="https://cdn.bootcss.com/vue-router/3.1.3/vue-router.js"></script>

<body>

  <div id="app">
    <p>{{ message }}</p>
    <p>
      <!-- 使用 router-link 组件来导航. -->
      <!-- 通过传入 `to` 属性指定链接. -->
      <!-- <router-link> 默认会被渲染成一个 `<a>` 标签 -->
      <a @click="$router.push({
                  path:'/cp1',
                    query: {p1:1,p2:2,t:+new Date()}
                })"
         >TO CP1</a>
      <a @click="$router.push({
                  path:'/cp2',
                    query: {p1:3,p2:4,t:+new Date()}
                })"
         >TO CP2</a>
    </p>
    <!-- 路由出口 -->
    <!-- 路由匹配到的组件将渲染在这里 -->
    <router-view></router-view>
  </div>

</body>
              
            
!

CSS

              
                
              
            
!

JS

              
                // cp1组件
const cp1 = {
  data: function() {
    return {
      name: "CP1"
    };
  },
  watch: {
    $route: "init"
  },
  methods: {
    init() {
      console.log("cp1.init 在这里获取前端路由参数,并根据路由参数查询后台数据",this.$route.query);
      //拿到路由参数,并填充到自身的data中
      //调用query方法
      this.query();
    },
    query(){
      // 拿到data中的数据,获取后台数据,并填充到自身data中
      this.name = "CP1"+JSON.stringify(this.$route.query);
    },
  },
  created() {
    console.log("cp1 created");
    this.init();
  },

  destroyed() {
    console.log("cp1 destroyed");
  },
  template: "<p>{{ name }}</p>"
};
// cp2组件
const cp2 = {
  data: function() {
    return {
      name: "CP2"
    };
  },
  watch: {
    $route: "init"
  },
  methods: {
    init() {
      console.log("cp2.init 在这里获取前端路由参数,并根据路由参数查询后台数据",this.$route.query);
    //拿到路由参数,并填充到自身的data中
      //调用query方法
      this.query()
    },
    query(){
      // 拿到data中的数据,获取后台数据,并填充到自身data中
      this.name = "CP2"+JSON.stringify(this.$route.query);
    },
  },
  created() {
    console.log("cp2 created");
    this.init();
  },

  destroyed() {
    console.log("cp2 destroyed");
  },
  template: "<p>{{ name }}</p>"
};
// 指定路由
const routes = [
  {
    path: "/cp1",
    component: cp1
  },
  {
    path: "/cp2",
    component: cp2
  }
];
// 生成VueRouter实例
const router = new VueRouter({ routes: routes });
// 在vue中加载vuerouter
var app = new Vue({
  router: router,
  el: "#app",
  data: {
    message: "Hello Vue!"
  }
});

              
            
!
999px

Console