-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use destructuring syntax for computed props in v2 mode - fixes #1069
- Loading branch information
1 parent
7fe139f
commit 99ea753
Showing
13 changed files
with
141 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
<script> | ||
export default { | ||
computed: { | ||
bar: foo => foo * 2 | ||
bar: ({ foo }) => foo * 2 | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<p>{scale(x)}</p> | ||
|
||
<script> | ||
export default { | ||
data: () => ({ | ||
x: 5, | ||
domain: [ 0, 10 ], | ||
range: [ 0, 100 ] | ||
}), | ||
|
||
computed: { | ||
scale: ({ domain, range }) => { | ||
return num => { | ||
const t = domain[0] + ( num - domain[0] ) / ( domain[1] - domain[0] ); | ||
return range[0] + t * ( range[1] - range[0] ); | ||
} | ||
} | ||
} | ||
}; | ||
</script> |
14 changes: 14 additions & 0 deletions
14
test/runtime/samples/computed-values-deconflicted/main-v2.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<span>{state}</span> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
x: 'waiting' | ||
}; | ||
}, | ||
computed: { | ||
state: ({ x }) => x | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<p>{foo}</p> | ||
|
||
<script> | ||
export default { | ||
computed: { | ||
foo: ({ a = 1 }) => a * 2 | ||
} | ||
}; | ||
</script> |
28 changes: 28 additions & 0 deletions
28
test/runtime/samples/computed-values-function-dependency/main-v2.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<p>{x}</p> | ||
|
||
<script> | ||
let _x; | ||
|
||
function getX () { | ||
return _x; | ||
} | ||
|
||
export default { | ||
data () { | ||
return { | ||
y: 1 | ||
}; | ||
}, | ||
|
||
computed: { | ||
xGetter ({ y }) { | ||
_x = y * 2; | ||
return getX; | ||
}, | ||
|
||
x ({ xGetter }) { | ||
return xGetter(); | ||
} | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<p>{a} + {b} = {c}</p> | ||
<p>{c} * {c} = {cSquared}</p> | ||
|
||
<script> | ||
export default { | ||
data: () => ({ | ||
a: 1, | ||
b: 2 | ||
}), | ||
|
||
computed: { | ||
c: ({ a, b }) => a + b, | ||
cSquared: ({ c }) => c * c | ||
} | ||
}; | ||
</script> |