我正在 React 中创建一个新应用程序。我想对横幅使用滑动滑块。横幅将从 API 中获取。当滑动器到达最后一张幻灯片时,如何将幻灯片附加到滑动器上。我正在使用onReachEnd函数来触发 api 调用。不确定如何动态附加幻灯片。
export const HeroSlider = () => {
const [pageNumber, setCurrentPageNumber ] = useState(0)
const { homeBannerData, isLoading, error } = useBannerData(pageNumber)
var dataHomeBanner = []
if (homeBannerData && homeBannerData.result) {
dataHomeBanner = dataHomeBanner.concat(homeBannerData.result.data)
}
function fetchBannerData() {
setCurrentPageNumber(pageNumber+1)
if (homeBannerData && homeBannerData.result) {
dataHomeBanner = dataHomeBanner.concat(homeBannerData.result.data)
}
}
return (
/* Hero Banner Start */
<section className="hero-slider">
<Swiper
slidesPerView={1}
watchSlidesVisibility = {true}
navigation
onReachEnd={() => fetchBannerData()}
autoHeight = {true}
>
{dataHomeBanner …Run Code Online (Sandbox Code Playgroud) 我在eclipse下收到以下警告:
WARNING: JSF1091: No mime type could be found for file dynamiccontent. To resolve this, add a mime-type mapping to the applications web.xml
Run Code Online (Sandbox Code Playgroud)
发布图片时会导致此错误
在primefaces composant下面:
<p:graphicImage value="#{bean.image}"/>
Run Code Online (Sandbox Code Playgroud)
Java Bean:
private StreamedContent image;
// Getter
public StreamedContent getImage() {
try {
JFreeChart jfreechart = ChartFactory.createPieChart3D("",
createDataset(), true, true, false);
PiePlot3D plot = (PiePlot3D) jfreechart.getPlot();
File chartFile = new File("dynamichart");
ChartUtilities.saveChartAsPNG(chartFile, jfreechart, 375, 300);
chartImage = new DefaultStreamedContent(new FileInputStream(
chartFile), "image/png");
return chartImage;
} catch (Exception e) {
e.printStackTrace();
return new …Run Code Online (Sandbox Code Playgroud) 我在尝试制作我的selectOneMenu内容时遇到了麻烦,这取决于另一个选择的值。第一个的内容来自我的数据库中的一个表并且运行良好,但第二个应该来自另一个表,但我无法使其工作。这是我的index.html,我只是想证明这是如何工作的:
<h:outputLabel value="Estado" styleClass="requiredLbl"/>
<p:selectOneMenu id="Estado" value="#{beanInscripcion.id_estado}" valueChangeListener="#{beanInscripcion.buscarMunicipios(event)}" >
<f:selectItem itemLabel="Elegir Estado" itemValue="" />
<f:selectItems value="#{beanInscripcion.estados}"
var="edo" itemLabel="#{edo.nombre_estado}" itemValue="#{edo.id_estado}" />
<p:ajax update="Municipio" listener="#{beanInscripcion.buscarMunicipios(event)}" />
</p:selectOneMenu>
<p:separator />
<h:outputLabel value="Municipio" styleClass="requiredLbl"/>
<p:selectOneMenu id="Municipio" value="municipio">
<f:selectItems value="#{beanInscripcion.municipios}"
var="mun" itemLabel="#{mun.nombre_municipio}" itemValue="#{mun.nombre_municipio}" />
</p:selectOneMenu>
Run Code Online (Sandbox Code Playgroud)
这是我的 Bean 部分,我应该在其中获取第二个菜单的内容:
@ManagedBean(name = "beanInscripcion")
@ViewScoped
public class BeanInscripcion implements Serializable {
static String strURL;
private List<Estado> estados;
private List<Municipio> municipios;
private int id_estado;
public BeanInscripcion() throws SQLException{
estados = new ArrayList<Estado>();
buscarEstados();
}
public …Run Code Online (Sandbox Code Playgroud) 我正在尝试将动态内容添加到我的mvc应用程序中.
我正在使用Steven Sanderson发布编辑可变长度列表,ASP.NET MVC 2样式,并且由于它,我有一些动态内容.由于我的应用程序的一些限制,我不得不改变基础礼品类.
问题是现在应用程序无法正常工作.
在我的模型中我有:
public class Gift
{
//public string Name { get; set; }
//public double Price { get; set; }
public List<string> MyList { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
现在,我在gifts参数中得到null值
[HttpPost]
public ActionResult Index(IEnumerable<Gift> gifts)
{
return View("Completed", gifts);
}
Run Code Online (Sandbox Code Playgroud)
谁可以帮我这个事?
编辑: 这是我的查看代码:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Enviro2011.Models.Gift>>" %>
<asp:Content ContentPlaceHolderID="HeadContent" runat="server">
<link rel="Stylesheet" href="../../Content/styles.css" />
<script type="text/javascript">
$(document).ready(function () {
$("#addItem").click(function () {
$.ajax({
url: this.href,
cache: false,
success: function (html) { …Run Code Online (Sandbox Code Playgroud) 我正在使用imagettftext()在图像上写动态文本,我希望它适合我的图像宽度.
如何通过文本长度计算字体大小?
早上的人.如何使我的javascript或jquery在动态生成的内容中工作.
基本上,我创建了基于用户点击导航菜单的内容生成内容的网页.
我遇到的问题:
通过搜索收集的信息:
jQuery.load()方法忽略与动态生成的内容一起提供的脚本标记.
所以我尝试以下方法:
示例 contact.php
<script type="text/javascript">
$(function() {
$("#submitUser").click(function(e) {
var fname = $("#fname").val();
$("#theresult").text(fname);
e.preventDefault();
});
});
<form id="contactForm">
<label for='fname' >First Name</label><br/>
<input id="fname" type="text" name="fname" maxlength="100" />
</form>
<div id="theresult"></div>
Run Code Online (Sandbox Code Playgroud)
当此contact.php动态生成到其他页面时,它不起作用.当我单击"提交"按钮时,控制台显示无响应.好像jquery不存在.
但是当我在浏览器中单独打开它时,它可以工作.
我试图在具有动态高度(增长内容)的div的底部获得一个粘性页脚.div需要浮动在页面中间(从左到右相同的距离).
我有以下HTML(剥离不相关的东西):
<html>
<body>
<div class="bodybackground">
<div class="container"><!-- floats in the middle -->
<div class="mainContainer"><!-- different color etc -->
<!-- content with dynamic height -->
</div>
<footer class="pagefooter"></footer>
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
和以下的CSS(也剥夺了无关的东西):
html {
height: 100%;
margin: 0px;
padding: 0px;
}
body {
margin: 0px;
height: 100%;
}
.bodybackground {
height: 100%;
min-height: 100%;
}
.container {
min-height: 100%;
display: inline-block; /* needed make it float in the middle of body */
top: 0px;
position: relative;
padding: 0px;
padding-bottom: …Run Code Online (Sandbox Code Playgroud) 我正在开发一个应用程序,我想在其中包含来自流的动态 XHTML 内容。为了处理这个问题,我编写了一个标记处理程序扩展,它将动态 XHTML 内容转储到输出组件,如下所示
UIOutput htmlChild = (UIOutput) ctx.getFacesContext().getApplication().createComponent(UIOutput.COMPONENT_TYPE);
htmlChild.setValue(new String(outputStream.toByteArray(), "utf-8"));
Run Code Online (Sandbox Code Playgroud)
这对于没有 JSF 标签的 XHTML 内容效果很好。如果我的动态 XHTML 内容中有 JSF 标记(例如 )<h:inputText value="#{bean.item}"/>,那么它们会以纯文本形式打印。我希望它们呈现为输入字段。我怎样才能实现这个目标?
我有一个带有 2 个轮播的网页,我必须根据用户操作在其中显示不同的项目。
新数据来自网上,我用fetch,把json解析成数组,都不错。
唯一的问题是我不能让新物品取代旋转木马中的旧物品。
对于我尝试过的简单示例
var carousel = $jq("#owl-genres");
for(...) {
carousel.owlCarousel()
.trigger('add.owl.carousel', [$jq('<div class="item">' + genres[i] + '</div>')])
.trigger('refresh.owl.carousel');
}
Run Code Online (Sandbox Code Playgroud)
但什么也没有发生。旧元素仍然存在,尽管方法执行并被.trigger执行。
我也试过
for(...) {
content += '<div class=\'item\'>' + genres[i] + '</div>'
carousel.html(content)
}
carousel.owlCarousel().trigger('refresh.owl.carousel');
Run Code Online (Sandbox Code Playgroud)
这确实将新项目添加到轮播中,但它们现在垂直堆叠,导航不起作用,我猜整个轮播都坏了。
那么在 Owl Carousel 2 中更换物品的正确方法是什么?
dynamic-content ×10
jquery ×3
javascript ×2
jsf ×2
php ×2
primefaces ×2
asp.net-mvc ×1
css ×1
facelets ×1
graphicimage ×1
html ×1
imagettftext ×1
java ×1
jsf-2 ×1
jsf-2.2 ×1
reactjs ×1
swiper.js ×1