javascript Vue1

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Vue1相关的知识,希望对你有一定的参考价值。

<div id="app">
  {{ message }}
</div>


<!-- Accent-colored raised button with ripple -->
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">
  Button
</button>
const postData = (url = ``, data = {}) => {
  // Default options are marked with *
    return fetch(url, {
        method: "POST", // *GET, POST, PUT, DELETE, etc.
        mode: "cors", // no-cors, cors, *same-origin
        cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
        credentials: "same-origin", // include, same-origin, *omit
        headers: {
            "Content-Type": "application/json; charset=utf-8",
            // "Content-Type": "application/x-www-form-urlencoded",
        },
        redirect: "follow", // manual, *follow, error
        referrer: "no-referrer", // no-referrer, *client
        body: JSON.stringify(data), // body data type must match "Content-Type" header
    })
    .then(response => response.json()) // parses response to JSON
    .catch(error => console.error(`Fetch Error =\n`, error));
};

const test1 = () => {
  postData(`https://manniru.firebaseio.com/vue/test1/.json`, {answer: 42})
  .then(data => console.log(data)) // JSON from `response.json()` call
  .catch(error => console.error(error));
}

var app = new Vue({
  el: '#app',
  data: {
    message: 'Hello Mannir!',
    myJson : null,
  },
  created() {
    // console.log(+new Date())
    fetch('https://manniru.firebaseio.com/forms/-Ky5HYCmhB7XTRYSH2PJ/.json')
    .then(response => { return response.json(); })
    .then(json => {
      //  message = json.name
      console.log(json.name)
    })
  }
})

test1();

以上是关于javascript Vue1的主要内容,如果未能解决你的问题,请参考以下文章

vue1.0 与 Vue2.0的一些区别 及用法

VUE1安装node.js

Vue1.0学习总结———Vue1.0自定义组件Vue1.0组件之间的通信

1216 Vue基础

VUE&Element简单介绍。

vue1-实例基础