Demand
I want to add a message board to my website.
Final effect
Browse effects
Implement leancloud.cn
https://leancloud.cn/
sign up for a moment!
- After logging in to the console, create an app server
- The development version of the good, and then fill in a name, create
- 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
- 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>
Initialization
The Help document provides three forms of attribute rules, namely ES5, ES6, server
To ensure that data is successfully accessed, the ping
server can be
ping uziwpzsm.api.lncld.net
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
- Of course, you can
TextObject
change it to your own name, like message.
You need to create a new one in your app earlyclass
- 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