peri hoki perihoki clarustologistics rimashaop.com angelpaintingtools.co.in vrjanaenergies.com cara scatter hitam maxwin spesifikasi scatter emas mahjong rtp mahjong wins 3 medan pola malam pgsoft cairkan 813jt keberuntungan tukang parkir cek rtp mahjong ways lebaran kisah inspiratif kuli bangunan menang mahjong wins peluang profit rtp mahjong ways 2 naik sopir angkot jackpot 89 juta mahjong wins temuan scatter jumat mahjong ways keajaiban malam menghidupkan suasana menang dengan gaya strategi cerdas mahjong putaran ajaib mahjong wins tumbang bahagia raup untung dengan trik scatter mahjong scatter hitam mahjong ways mengantarkan kemenangan tak terduga fenomena scatter hitam saat jam sepi server kemenangan besar dari scatter hitam mahjong ways pekerja serabutan raih jackpot mengagumkan di mahjong ways potensi emas setiap spin mahjong ways waktu spin terbaik untuk scatter hitam tukang becak raih rejeki di mahjong
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 282
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_cookie_params(): Cannot change session cookie parameters when headers already sent
Filename: Session/Session.php
Line Number: 294
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 304
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 314
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 315
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 316
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 317
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 375
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: drivers/Session_files_driver.php
Line Number: 108
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_save_handler(): Cannot change save handler when headers already sent
Filename: Session/Session.php
Line Number: 110
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_start(): Cannot start session when headers already sent
Filename: Session/Session.php
Line Number: 143
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
Two-way binding với Checkbox trong VueJS 2 - Freetuts
GIỚI THIỆU
CĂN BẢN
NÂNG CAO
VUEJS 2X CĂN BẢN
CÁC CHỦ ĐỀ
BÀI MỚI NHẤT
Two-way binding với Checkbox trong VueJS 2
Trong bài tập này, mình sẽ tiếp tục tìm hiểu Two-way binding trong VueJS 2, tập trung vào việc làm việc với checkbox và liên kết trạng thái của nó với một biến trong Vue instance. Hãy cùng nhau thực hiện bài tập Two-way binding với checkbox và hiển thị trạng thái tương ứng ngay bên dưới nó.
Two-way Binding với Checkbox trong VueJS 2
Mình sẽ bắt đầu với việc tạo một checkbox
và liên kết trạng thái của nó với một biến trong Vue instance. Đồng thời, hiển thị trạng thái đó ngay bên dưới checkbox để có trải nghiệm thực tế và minh họa cách Two-way binding hoạt động.
File index.html
:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vue Two-way Binding with Checkbox</title>
<!-- Thêm đoạn CSS -->
<style>
body {
font-family: 'Arial', sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-color: #f4f4f4;
}
#app {
text-align: center;
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
input {
margin-bottom: 10px;
}
p {
font-size: 16px;
color: #333;
}
</style>
</head>
<body>
<div id="app">
<input type="checkbox" v-model="isChecked">
<p>Trạng thái checkbox: {{ isChecked ? 'Đã chọn' : 'Chưa chọn' }}</p>
</div>
<!-- VueJS -->
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<!-- Main JavaScript file -->
<script src="main.js"></script>
</body>
</html>
File main.js
:
// Tạo một Vue instance
var app = new Vue({
el: '#app',
data: {
isChecked: false // Biến để lưu trữ trạng thái của checkbox
}
});
Trong đoạn mã trên:
Sử dụng directive v-model
để liên kết trạng thái của checkbox
với biến isChecked
trong Vue instance.
Hiển thị trạng thái của biến này ngay bên dưới checkbox
bằng cách sử dụng {{ isChecked ? 'Đã chọn' : 'Chưa chọn' }}.
Như vậy, bạn đã tạo một ứng dụng sử dụng Two-way binding với checkbox trong VueJS 2. Khi checkbox được chọn hoặc bỏ chọn, trạng thái sẽ tự động cập nhật và hiển thị ngay bên dưới nó.
Trong bài tập này, mình đã thành công trong việc sử dụng Two-way binding của VueJS 2 để làm việc với checkbox. Việc liên kết trạng thái của checkbox với một biến trong Vue instance và hiển thị trạng thái đó ngay lập tức là một ví dụ cụ thể về cách VueJS giúp chúng ta quản lý trạng thái ứng dụng một cách thuận tiện. Hãy áp dụng những khái niệm này vào các dự án của bạn để tận dụng tối đa sức mạnh của VueJS.
Bài giải
-------------------- ######## --------------------
Câu hỏi thường gặp liên quan:
Cùng chuyên mục: