Small white How to add a database to the website

Source: Internet
Author: User

Demand

I want to add a message board to my website.

Final effect

Browse effects

Implement leancloud.cn
    1. https://leancloud.cn/sign up for a moment!
    2. After logging in to the console, create an app server
    3. The development version of the good, and then fill in a name, create
    4. Get access to one of the application points we created
Configuration of JS

Detailed Help documentation

Here is the js configuration please don't forget to tickjs

    1. Because it is a project of a personal website, it is introduced directly in the index.html
<script src="//cdn1.lncld.net/static/js/3.5.0/av-min.js"></script>
    1. Initialization
      The Help document provides three forms of attribute rules, namely ES5, ES6, server

    2. To ensure that data is successfully accessed, the ping server can be

      ping uziwpzsm.api.lncld.net

    3. Add code to test

      var TestObject = AV.Object.extend(‘TestObject‘);  // TestObject 为对应的图3的TestObjectvar testObject = new TestObject()testObject.save({  words: ‘Hello World!‘   // 存入一个key为words 指为Hello World}).then(function(object) {  alert(‘LeanCloud Rocks!‘)  // 当存入成功 返回})

Overall JS Code

const appId = ‘XXXXX‘;  // 你的appIdconst appKey = ‘XXX‘; // 你的appKeyAV.init({ appId, appKey });const TestObject = AV.Object.extend(‘TestObject‘);  // TestObject 为对应的图3的TestObjectconst testObject = new TestObject()testObject.save({  words: ‘Hello World!‘   // 存入一个key为words 指为Hello World}).then((object) => {  alert(‘LeanCloud Rocks!‘)  // 当存入成功 返回})
<body><sectionid="Message"class="Message" >      Message      <ul>      </ul>      <form>        <labelclass="Name">          <inputtype="Text"name="Name"placeholder="NAME">          <iclass="Iconfont icon-user"></i>        </label>        <labelclass="Content">          <inputtype="Text"name="Content"placeholder="MESSAGE">          <iclass="Iconfont icon-message"></i>        </label>        <inputclass="Send"type="Submit"value="SEND >">      </form>    </section>  </div>  <scriptsrc="//cdn1.lncld.net/static/js/3.5.0/av-min.js"></script></body>
Post-language
    1. Of course, you can TextObject change it to your own name, like message.
      You need to create a new one in your app earlyclass
    2. This method is suitable for 小型业务 or 个人业务 , for example, my message boards. Do not use in large business, or you may also consider paying

Small white How to add a database to the website

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.