Now.js เป็น JavaScript Framework ที่ทันสมัย รวดเร็ว และใช้งานง่าย พัฒนาเว็บแอปพลิเคชันได้อย่างมีประสิทธิภาพด้วยเครื่องมือที่ครบครัน
Now.js มาพร้อมกับฟีเจอร์ที่ทรงพลังและใช้งานง่าย เพื่อการพัฒนาที่มีประสิทธิภาพ
เร็วกว่า React ถึง 3 เท่า ด้วยเทคโนโลยี Virtual DOM แบบใหม่และ Tree Shaking ที่ชาญฉลาด
Syntax ที่เข้าใจง่าย เรียนรู้ได้เร็ว พร้อม CLI tools และ Hot Reload สำหรับการพัฒนาที่รวดเร็ว
รองรับทุกอุปกรณ์ ตั้งแต่มือถือจนถึงเดสก์ท็อป ด้วยระบบ Grid และ Flexbox ที่ทันสมัย
ป้องกัน XSS, CSRF และช่องโหว่ต่างๆ ด้วยระบบรักษาความปลอดภัยที่แข็งแกร่ง
Server-side Rendering และ Static Site Generation สำหรับ SEO ที่ดีและโหลดเร็ว
ระบบจัดการ State ที่ทรงพลัง รองรับ Redux, Vuex และ State Management แบบใหม่
เรียนรู้ Now.js ผ่านตัวอย่างโค้ดที่เข้าใจง่าย
import { Component } from 'now.js';
class TodoApp extends Component {
constructor() {
super();
this.state = {
todos: [],
inputValue: ''
};
}
addTodo() {
const { todos, inputValue } = this.state;
if (inputValue.trim()) {
this.setState({
todos: [...todos, {
id: Date.now(),
text: inputValue,
completed: false
}],
inputValue: ''
});
}
}
render() {
return `
<div class="todo-app">
<h1>Todo List</h1>
<input
type="text"
value="{inputValue}"
@input="updateInput"
placeholder="เพิ่มรายการใหม่..."
/>
<button @click="addTodo">เพิ่ม</button>
<ul>
{todos.map(todo => `
<li class="{todo.completed ? 'completed' : ''}">
{todo.text}
</li>
`).join('')}
</ul>
</div>
`;
}
}
import { Router, Route } from 'now.js/router';
const router = new Router({
mode: 'history',
base: '/'
});
// กำหนดเส้นทาง
router.add([
{
path: '/',
component: HomePage,
name: 'home'
},
{
path: '/about',
component: AboutPage,
name: 'about'
},
{
path: '/user/:id',
component: UserPage,
name: 'user',
beforeEnter: (to, from, next) => {
// ตรวจสอบสิทธิ์ก่อนเข้าหน้า
if (isAuthenticated()) {
next();
} else {
next('/login');
}
}
}
]);
// เริ่มต้น Router
router.start('#app');
import { Store } from 'now.js/store';
// สร้าง Store
const store = new Store({
state: {
user: null,
isLoggedIn: false,
products: []
},
mutations: {
setUser(state, user) {
state.user = user;
state.isLoggedIn = !!user;
},
addProduct(state, product) {
state.products.push(product);
}
},
actions: {
async loginUser({ commit }, credentials) {
try {
const user = await api.login(credentials);
commit('setUser', user);
return user;
} catch (error) {
throw new Error('เข้าสู่ระบบไม่สำเร็จ');
}
},
async fetchProducts({ commit }) {
const products = await api.getProducts();
commit('setProducts', products);
}
}
});
export default store;
ติดตั้งและเริ่มใช้งาน Now.js ได้ภายใน 5 นาที
npm install -g @nowjs/cli
now create my-app
cd my-app && npm start
เรียนรู้ แบ่งปัน และพัฒนาไปด้วยกันกับชุมชน Now.js