当前位置:网站首页>v-if,v-else,v-for
v-if,v-else,v-for
2022-07-27 16:21:00 【qq_42042158】
条件判断
v-if,v-else 实现判断
代码
<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>demo-02</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
</head>
<body>
<div id="app">
<p v-if="type==='A'">type是A</p>
<p v-else-if="type==='B'">type是B</p>
<p v-else>type是C</p>
</div>
<script> var app = new Vue({
el: '#app', data: {
type: 'B' } }) </script>
</body>
</html>
运行结果
循环
从数组todos里面取出的每一项为todo
<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>demo-04</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
</head>
<body>
<div id="app">
<ol>
<li v-for="todo in todos">
{
{ todo.text }}
</li>
</ol>
</div>
<script> var app = new Vue({
el: '#app', data: {
todos: [ {
text: '学习 JavaScript' }, {
text: '学习 Vue' }, {
text: '整个牛项目' } ] } }) </script>
</body>
</html>
运行结果
边栏推荐
- Quick access to website media resources
- JS to achieve smooth scrolling of pages or DOM elements
- TypeError: conv2d(): argument ‘padding‘ (position 5) must be tuple of ints, not str【报错】
- Zhaoqi scientific and technological innovation introduces high-level talents at home and abroad and connects innovation and entrepreneurship projects
- Interceptor拦截器
- Redis注解
- Vue uses keep alive to realize page caching
- 飞机大战碰撞检测
- I'm stupid. When completable future is used with openfegin, it even reports an error
- Infrared hyperspectral survey
猜你喜欢
随机推荐
Uploading and downloading of files
was not registered for synchronization because synchronization is not active[已解决]
INSUFFICIENT_ ACCESS_ ON_ CROSS_ REFERENCE_ ENTITY APEX / SALESFORCE
JDBC MySQL 02 data access and Dao mode
`this.$emit` 子组件给父组件传递多个参数
智能失眠治疗仪产品-DLT8P68SA-杰力科创
Whole body multifunctional massage instrument chip-dltap602sd
飞机大战敌机出场
Idea 2020.1 Community Edition download experience
低噪负离子风扇触摸IC
Overview of Baidu map technology, and application development of basic API and webapi
TS study notes class
C basic concepts list description suggestions collection
MySQL 03 高级查询(一)
TS learning notes interface
Led learning eye protection table lamp touch chip-dlt8t10s-jericho
Zhaoqi scientific and technological innovation introduces high-level talents at home and abroad and connects innovation and entrepreneurship projects
Uni app form submit button send request
内网的公司邮箱服务器怎么发外部邮件
Runtimeerror: output with shape [1, 256, 256] doesn't match the broadcast shape [3, 256, 256] [error]









