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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

              
                <!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>宣言的レンダリング</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <h1>基本構文 Hello Vue</h1>
        {{ message }}
    </div>
    <script>
        var app = new Vue({ // Vueインスタンス //「app」という変数 
            el: "#app", //リアクティブするDOM要素「#app」を指定
            data :{
                message : "はじめてのVueアプリケーション"
            }
        })
    </script>

    <hr>

    <div id="app2">
        <h1>v-bind 要素の属性を束縛(バインディング)</h1>
        <span v-bind:title="message">
            v-bind 属性を利用して、titleタグ内にdataの値が入っている
        </span>
    </div>
    <script>
        var app2 = new Vue({
            el: "#app2",
            data:{
                message: 'You loaded this page on ' + new Date().toLocaleString()
            }
        })
    </script>

    <hr>

    <div id="app3">
        <h1>v-if 条件分岐とループ</h1>
        <span v-if="seen">Now You See me</span>
    </div>

    <script>
        var app3 = new Vue({
            el: "#app3",
            data: {
                seen: true
                //seen: false
            }
        })
    </script>

    <hr>

    <div id="app4">
        <h1>v-for ループ</h1>
        <ul>
            <li v-for="todo in todos">
                {{ todo.text }}
            </li>
        </ul>
    </div>
    <script>
        var app4 = new Vue({
            el: "#app4",
            data: {
                todos: [
                    { text:"あああ" },
                    { text:"いいい" },
                    { text:"ううう" }
                ]
            }
        })
    </script>

    <hr>

    <div id="app5">
        <h1>v-on:click ユーザー入力の制御</h1>
        <p>{{ message }}</p>
        <button v-on:click="reverseMessage">文言を逆にする</button>
    </div>
    <script>
        var app5 = new Vue({
            el: "#app5",
            data: {
                message: "Hello Vue.js"
            },
            methods:{
                reverseMessage: function(){
                    //「message」の文言を、分割、逆に並べて、くっつける
                    this.message = this.message.split('').reverse().join('')
                }
            }
        })
    </script>

    <hr>

    <div id="app6">
        <h1>v-model 双方向バインディング</h1>
        <p>{{ message }}</p>
        <input v-model="message">
    </div>
    <script>
        var app6 = new Vue({
            el: "#app6",
            data: {
                message:"Hello"
            }
        })
    </script>

    <hr>

    <div id="app7">
        <h1>コンポーネント</h1>
        <ol>
            <!-- todos 配列にある各 todo に対して todo-item コンポーネントのインスタンスを作成する -->
            <todo-item
                v-for="item in groceryList"
                v-bind:todo="item"
                v-bind:key="item.id"
            ></todo-item>
        </ol>
        <ol>
            <!-- todos 配列にある各 todo に対して todo-item コンポーネントのインスタンスを作成する -->
            <todo-item
                v-for="item in groceryList"
                v-bind:todo="item"
                v-bind:key="item.id"
            ></todo-item>
        </ol>
    </div>
    <script>
        Vue.component('todo-item',{
            // todo-item コンポーネントはカスタム属性のような "プロパティ" で受け取ります。
            // このプロパティは todo と呼ばれます。
            props: ['todo'], //非推奨
            template: '<li>{{ todo.text }}</li>'
        })
        var app7 = new Vue({
            el:"#app7",
            data:{
                groceryList:[
                    { id:0, text:'あああ'},
                    { id:1, text:'いいい'},
                    { id:2, text:'ううう'},
                ]
            }
        })
    </script>

    <hr>

    <h1>コンポーネント props親子関係</h1>
    <div id="oyako">
        <parent></parent>
    </div>
    <script>
        Vue.component('parent', {
            template: '<child></child>'
        });

        Vue.component('child', {
            template: '<p>子コンポーネント</p>'
        })

        new Vue({
            el: '#oyako'
        })
    </script>


</body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console