我已经阅读了很多关于此的文章,似乎有多种方法可以做到这一点,许多作者建议不要使用某些实现。
为了简化这个过程,我创建了一个我想要实现的非常简单的版本。
我有一个父 Vue,parent.vue。它有一个按钮:
<template>
<div>
<button v-on:click="XXXXX call method in child XXXX">Say Hello</button>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
在子Vue中,child.vue我有一个带函数的方法:
methods: {
sayHello() {
alert('hello');
}
}
Run Code Online (Sandbox Code Playgroud)
我想sayHello()在单击父级中的按钮时调用该函数。
我正在寻找执行此操作的最佳实践方法。我看到的建议包括事件总线、子组件引用和道具等。
在我的方法中执行函数的最简单方法是什么?
抱歉,这看起来确实非常简单,但我确实尝试过做一些研究。
谢谢!

我无法弄清楚是什么控制了这些内联表单元素之间的边距.例如,两个文本输入字段之间的边距.
编辑:我知道如何控制以改变这些边距,但为什么它们之间存在差距.我在引导程序中找不到任何CSS,它们负责它们之间的这些3或4px边距.
请参阅下面的代码段.淡出工作正常,但任何想法为什么它不会淡入?
我的HTML:
<div id="id10574"><span style="font-size:6em">?</span></div>
<button id="b1">Fade Out</button>
<button id="b2">Fade In</button>
<script src="fade.js"></script>
Run Code Online (Sandbox Code Playgroud)
和JS:
var cat = document.getElementById("id10574");
cat.style.opacity = 1;
function fadeout() {
if (cat.style.opacity > 0) {
cat.style.opacity = (cat.style.opacity - 0.01);
setTimeout( fadeout, 10 );
} else {
}
}
function fadein() {
if (cat.style.opacity < 1) {
cat.style.opacity = (cat.style.opacity + 0.01);
setTimeout( fadein, 10 );
} else {
}
}
document.getElementById("b1").addEventListener("click", fadeout , false);
document.getElementById("b2").addEventListener("click", fadein , false);
Run Code Online (Sandbox Code Playgroud)
我真的很难过这个.尝试制作一个适用于IE8(企业环境中的Sharepoint)的简单效果.
谢谢!
似乎有一些例子说明了如何做类似的事情,但都与我的情况略有不同。我正在从 API(在 JS 文件中)加载一些股票数据,然后在我的 VUE 中使用它。我想使用从 API 数据编译的新数组来更新我的图表系列,但它不起作用,而且我没有收到任何错误。
我的 Vue 看起来像这样:
<template>
<div>
<highcharts :options="chartOptions" :updateArgs="[true, false]" ref="highcharts"></highcharts>
</div>
</template>
<script>
import appService from '../stock_prices'
import {Chart} from 'highcharts-vue'
export default {
name: 'stocks',
props: {
msg: String
},
data () {
return {
chartOptions: {
mySeries: [],
info: {},
updateArgs: [true, true, true],
series: [{
data: [1,2,3,4,5,6,7]
}],
}
},
}
}, //data
components: {
highcharts: Chart
},
methods: {
updateSeries() {
for (var i = 0; i < …Run Code Online (Sandbox Code Playgroud) 我想知道是否存在一种简单而可靠的方法来设置 ul 和 li 元素的样式,以便在使用 list-style: outside 时,li 元素与其上方的内容对齐,或者与它所在的内容框对齐,没有边距或填充。
考虑一下:(http://jsfiddle.net/Um5L9/2/)
<div id = "container1">
<span>Something</span>
<ul>
<li>
<div>One</div>
<div>Some more text or content here</div>
</li>
<li>
<div>One</div>
<div>Some more text or content here</div>
</li>
<li>
<div>One</div>
<div>Some more text or content here</div>
</li>
</ul>
</div>
body {
margin:20px;
border: 1px solid #333;
}
ul {
list-style: square outside none;
}
Run Code Online (Sandbox Code Playgroud)
结果将是这样的:

我想要的是这个:

只需添加一些填充即可轻松完成:
ul {
list-style: square outside none;
padding-left:15px;
}
Run Code Online (Sandbox Code Playgroud)
但是肯定有比设置像素边距更好的方法。也许适用于所有字体大小的东西?
谢谢!
编辑
只想补充一点,我需要 li 的两个孩子都排在彼此下面
我有这个:
<fieldset id="booom">
<label><INPUT TYPE="checkbox" NAME="a" VALUE="a">something></label>
<label><INPUT TYPE="checkbox" NAME="b" VALUE="b">something></label>
<label><INPUT TYPE="checkbox" NAME="c" VALUE="c">something></label>
</fieldset>
<input type="button" id="answer" value="submit">
Run Code Online (Sandbox Code Playgroud)
如果在提交时取消选中fieldset'booom'中的所有复选框,我如何查看jQuery?
所以:
if (all checkboxes from parent 'booom' are unchecked) {
alert("something")
}
Run Code Online (Sandbox Code Playgroud)
我找到了很多关于此的帖子,但没有一个带有按钮和警告框的实际简单工作样本:)
谢谢!
我将有一个非常长的图像阵列,我知道应该有一个更好的方法来编写它.
目前它看起来像这样:
var imgnames=new Array("img[src*='edit']", "img[src*='delete']", "img[src*='copy']");
var imgs = document.querySelectorAll(imgnames);
Run Code Online (Sandbox Code Playgroud)
但是我希望通过这样的方式缩短数组中项目的名称:
var imgnames=new Array("edit", "delete", "copy");
var imgs = document.querySelectorAll("img[src*='???imgnames???']");
Run Code Online (Sandbox Code Playgroud)
但是不能让它工作,我想我的引言都在错误的地方.谢谢!