12/08/2018, 17:00

Computed, Watcher và Filter trong Vue.js

Computed Properties Computed là gì? Mình xin lấy ví dụ trước, sau đó sẽ giải thích về cái này. Quay lại ví dụ hôm trước như sau. Trong file index.html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> < ...

Computed Properties

Computed là gì? Mình xin lấy ví dụ trước, sau đó sẽ giải thích về cái này. Quay lại ví dụ hôm trước như sau. Trong file index.html

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>Getting Started with Vuejs</title>
</head>
<body>
    <div id="app">
        <p>{{ message }}</p>
    </div>
</body>
<script type="text/javascript" src="app.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/vue"></script>
</html>

app.js :

var app = new Vue({
    el: '#app',
    data: {
      message: 'Hello World!'
    }
})  

Chạy thử và kết quả là : Hello World! Nhưng mà không phải lúc nào dữ liệu bản hiển thị ra cũng được đẹp, và đơn giản như vậy. Ví dụ như giờ mình không muốn là Hello World! nữa, mình muốn viết hoa các chữ cái của nó thì sao. Vào html sửa lại luôn như vậy             </div>
            
            <div class=

0